diff --git a/R/count_occurrences.R b/R/count_occurrences.R index eace45381d..b289565a8f 100644 --- a/R/count_occurrences.R +++ b/R/count_occurrences.R @@ -132,11 +132,13 @@ a_count_occurrences <- function(df, .labels = NULL, .indent_mods = NULL, na_str = NA_character_) { - denom = match.arg(denom) + denom <- match.arg(denom) x_stats <- s_count_occurrences( df = df, denom = denom, .N_col = .N_col, .df_row = .df_row, drop = drop, .var = .var, id = id ) - if (is.null(unlist(x_stats))) return(NULL) + if (is.null(unlist(x_stats))) { + return(NULL) + } x_lvls <- names(x_stats[[1]]) # Fill in with formatting defaults if needed diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index eed20a8286..083a6f4c80 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -93,7 +93,7 @@ get_stats <- function(method_groups = "analyze_vars_numeric", stats_in = NULL, a # Mismatch with counts and numeric if (any(grepl("counts", method_groups)) && stats_in_pval_value != "pval_counts" || - any(grepl("numeric", method_groups)) && stats_in_pval_value != "pval") { + any(grepl("numeric", method_groups)) && stats_in_pval_value != "pval") { # nolint stop( "Inserted p-value (", stats_in_pval_value, ") is not valid for type ", type_tmp, ". Use ", paste(ifelse(stats_in_pval_value == "pval", "pval_counts", "pval")), @@ -262,7 +262,8 @@ get_labels_from_stats <- function(stats, labels_in = NULL, row_nms = NULL) { #' get_indents_from_stats(all_cnt_occ, indents_in = 3L) #' get_indents_from_stats(all_cnt_occ, indents_in = list(count = 2L, count_fraction = 5L)) #' get_indents_from_stats( -#' all_cnt_occ, indents_in = list(a = 2L, count.a = 1L, count.b = 5L), row_nms = c("a", "b") +#' all_cnt_occ, +#' indents_in = list(a = 2L, count.a = 1L, count.b = 5L), row_nms = c("a", "b") #' ) #' #' @export @@ -277,7 +278,9 @@ get_indents_from_stats <- function(stats, indents_in = NULL, row_nms = NULL) { checkmate::assert_integerish(indents_in, null.ok = TRUE) } - if (is.null(names(indents_in)) && length(indents_in) == 1) return(indents_in) + if (is.null(names(indents_in)) && length(indents_in) == 1) { + return(indents_in) + } if (!is.null(row_nms)) { ret <- rep(0L, length(stats) * length(row_nms)) diff --git a/tests/testthat/test-utils_default_stats_formats_labels.R b/tests/testthat/test-utils_default_stats_formats_labels.R index ddd929d1e1..baa0d7a154 100644 --- a/tests/testthat/test-utils_default_stats_formats_labels.R +++ b/tests/testthat/test-utils_default_stats_formats_labels.R @@ -149,8 +149,10 @@ testthat::test_that("get_labels_from_stats works as expected", { labels_in = c("c" = "Lvl c:", "count_fraction.a" = "CF: A", "count.b" = "Count of b"), row_nms = c("a", "b", "c") ), - c(count.a = "a", count.b = "Count of b", count.c = "Lvl c:", - count_fraction.a = "CF: A", count_fraction.b = "b", count_fraction.c = "Lvl c:") + c( + count.a = "a", count.b = "Count of b", count.c = "Lvl c:", + count_fraction.a = "CF: A", count_fraction.b = "b", count_fraction.c = "Lvl c:" + ) ) }) @@ -178,8 +180,10 @@ testthat::test_that("get_indents_from_stats works as expected", { indents_in = c("c" = 3L, "count_fraction.a" = 1L, "count.b" = 2L), row_nms = c("a", "b", "c") ), - c(count.a = 0L, count.b = 2L, count.c = 3L, - count_fraction.a = 1L, count_fraction.b = 0L, count_fraction.c = 3L) + c( + count.a = 0L, count.b = 2L, count.c = 3L, + count_fraction.a = 1L, count_fraction.b = 0L, count_fraction.c = 3L + ) ) })