diff --git a/R/analyze_variables.R b/R/analyze_variables.R index 8bc3ca1d16..6256dd85ea 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -488,7 +488,7 @@ a_summary_internal <- function(x, # Check for custom labels from control_analyze_vars if (is.numeric(x)) { - default_labels <- get_stats("analyze_vars", type, add_pval = compare) %>% + default_labels <- .stats %>% get_label_from_stats() for (i in intersect(.stats, c("mean_ci", "mean_pval", "median_ci", "quantiles"))) { if (!i %in% names(.labels) || .labels[[i]] == default_labels[[i]]) { diff --git a/R/summary_stats.R b/R/summary_stats.R index 4d1da84488..91f82e8a81 100644 --- a/R/summary_stats.R +++ b/R/summary_stats.R @@ -79,7 +79,7 @@ summary_custom <- function(type = "numeric", lifecycle::deprecate_warn( "0.9.0.9001", "summary_custom()", - details = "Please use get_stats and get_* directly instead." + details = "Please use `get_stats`, `get_format_from_stats`, and `get_label_from_stats` directly instead." ) .stats <- get_stats("analyze_vars", type, stats_custom, add_pval = include_pval) diff --git a/R/utils_defaults_handling.R b/R/utils_defaults_handling.R index 74ffe38523..f2f178557b 100644 --- a/R/utils_defaults_handling.R +++ b/R/utils_defaults_handling.R @@ -10,17 +10,17 @@ assert_allowed_types <- function(type) { invisible(default_type) } -#' Defaults for stats methods names and their relative formats/labels +#' Defaults for statistical method names and their associated formats & labels #' #' @description `r lifecycle::badge("experimental")` #' #' Utility functions to get valid statistic methods for different method groups -#' (`.stats`) and their relative formats (`.formats`) and labels (`.labels`). This utility +#' (`.stats`) and their associated formats (`.formats`) and labels (`.labels`). This utility #' is used across `tern`, but some of its working principles can be seen in [analyze_vars()]. #' See notes to understand why this is experimental. #' -#' @param stats (`character`) \cr statistical methods to get defaults formats for. -#' @param type (`character`) \cr type of data and result desired. Some stats defaults (and their formats and labels), +#' @param stats (`character`)\cr statistical methods to get defaults formats for. +#' @param type (`character`)\cr type of data and result desired. Some stats defaults (and their formats and labels), #' differ if you need to analyze different type of values. See Details for available options. #' #' @details @@ -101,8 +101,8 @@ get_stats <- function(method_groups, type = NULL, stats_in = NULL, add_pval = FA "geom_cv" ), stop( - "The inserted method_group (", mgi, ")", - ifelse(add_typ_to_err, paste0(" and type (", paste0(typ, collapse = " "), ")"), ""), + "The selected method group (", mgi, ")", + ifelse(add_typ_to_err, paste0(" with type(s) ", paste0(typ, collapse = ", ")), ""), " has no default statistical method." ) ) @@ -126,7 +126,7 @@ get_stats <- function(method_groups, type = NULL, stats_in = NULL, add_pval = FA "numeric" %in% type && stats_in_pval_value != "pval") { stop( "Inserted p-value (", stats_in_pval_value, ") is not valid for type ", - type, ". Use the other from pval pval_counts." + type, ". Use ", paste(ifelse(stats_in_pval_value == "pval", "pval_counts", "pval")), " instead." ) } @@ -155,12 +155,12 @@ get_stats <- function(method_groups, type = NULL, stats_in = NULL, add_pval = FA # If intersect did not find matches (and no pval?) -> error if (length(out) == 0) { stop( - "The selected method_groups (", paste0(method_groups, collapse = " "), ")", + "The selected method group(s) (", paste0(method_groups, collapse = ", "), ")", ifelse(is.null(type), "", paste0( - " and types (", - paste0(type, collapse = " "), ")" + " with type(s) ", + paste0(type, collapse = ", ") )), - " does not have the required default statistical methods:\n", + " do not have the required default statistical methods:\n", paste0(stats_in, collapse = " ") ) }