From 16a3b1111cc6d63d211ae266fecbd7af340cd8bb Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 17:00:06 -0400 Subject: [PATCH 01/16] Add tern_default_stats, improve documentation --- R/utils_default_stats_formats_labels.R | 154 +++++++++++++++++++------ man/default_stats_formats_labels.Rd | 56 +++++---- 2 files changed, 151 insertions(+), 59 deletions(-) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 5adda079fa..88d7aa8c5a 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -1,13 +1,11 @@ -#' Defaults for statistical method names and their associated formats & labels +#' Get default statistical methods and their associated formats, labels, and indent modifiers #' #' @description `r lifecycle::badge("experimental")` #' #' Utility functions to get valid statistic methods for different method groups -#' (`.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 or labels for. +#' (`.stats`) and their associated formats (`.formats`), labels (`.labels`), and indent modifiers +#' (`.indent_mods`). 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. #' #' @details #' Current choices for `type` are `counts` and `numeric` for [analyze_vars()] and affect `get_stats()`. @@ -19,18 +17,18 @@ #' @name default_stats_formats_labels NULL -#' @describeIn default_stats_formats_labels Get defaults statistical methods for different -#' groups of methods. +#' @describeIn default_stats_formats_labels Get statistics available for a given method +#' group (analyze function). #' -#' @param method_groups (`character`)\cr indicates the group of statistical methods that -#' we need the defaults from. A character vector can be used to collect more than one group of statistical -#' methods. -#' @param stats_in (`character`)\cr desired stats to be picked out from the selected method group. -#' @param add_pval (`flag`)\cr should `"pval"` or `"pval_counts"` (if `method_groups` contains +#' @param method_groups (`character`)\cr indicates the statistical method group (`tern` analyze function) +#' to retrieve default statistics for. A character vector can be used to specify more than one statistical +#' method group. +#' @param stats_in (`character`)\cr statistics to retrieve for the selected method group. +#' @param add_pval (`flag`)\cr should `"pval"` (or `"pval_counts"` if `method_groups` contains #' `"analyze_vars_counts"`) be added to the statistical methods? #' #' @return -#' * `get_stats()` returns a character vector with all default statistical methods. +#' * `get_stats()` returns a `character` vector of statistical methods. #' #' @examples #' # analyze_vars is numeric @@ -67,19 +65,10 @@ get_stats <- function(method_groups = "analyze_vars_numeric", stats_in = NULL, a # Loop for multiple method groups for (mgi in method_groups) { # Main switcher - out_tmp <- switch(mgi, - "count_occurrences" = c("count", "count_fraction", "count_fraction_fixed_dp", "fraction"), - "summarize_num_patients" = c("unique", "nonunique", "unique_count"), - "analyze_vars_counts" = c("n", "count", "count_fraction", "n_blq"), - "analyze_vars_numeric" = c( - "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", - "mean_sdi", "mean_pval", "median", "mad", "median_ci", "quantiles", "iqr", - "range", "min", "max", "median_range", "cv", "geom_mean", "geom_mean_ci", - "geom_cv" - ), - stop( - "The selected method group (", mgi, ") has no default statistical method." - ) + out_tmp <- switch( + mgi, + tern_default_stats, + stop("The selected method group (", mgi, ") has no default statistical method.") ) out <- unique(c(out, out_tmp)) } @@ -131,14 +120,14 @@ get_stats <- function(method_groups = "analyze_vars_numeric", stats_in = NULL, a out } -#' @describeIn default_stats_formats_labels Get formats from vector of statistical methods. If not -#' present `NULL` is returned. +#' @describeIn default_stats_formats_labels Get formats corresponding to a list of statistics. #' #' @param formats_in (named `vector`) \cr inserted formats to replace defaults. It can be a #' character vector from [formatters::list_valid_format_labels()] or a custom format function. #' #' @return -#' * `get_formats_from_stats()` returns a named list of formats, they being a value from +#' * `get_formats_from_stats()` returns a named vector of formats (if present in either +#' `tern_default_formats` or `formats_in`, otherwise `NULL`). Values can be taken from #' [formatters::list_valid_format_labels()] or a custom function (e.g. [formatting_functions]). #' #' @note Formats in `tern` and `rtables` can be functions that take in the table cell value and @@ -187,9 +176,9 @@ get_formats_from_stats <- function(stats, formats_in = NULL) { out } -#' @describeIn default_stats_formats_labels Get labels from vector of statistical methods. +#' @describeIn default_stats_formats_labels Get labels corresponding to a list of statistics. #' -#' @param labels_in (named `vector`)\cr inserted labels to replace defaults. +#' @param labels_in (named `vector` of `character`)\cr inserted labels to replace defaults. #' @param row_nms (`character`)\cr row names. Levels of a `factor` or `character` variable, each #' of which the statistics in `.stats` will be calculated for. If this parameter is set, these #' variable levels will be used as the defaults, and the names of the given custom values should @@ -197,8 +186,8 @@ get_formats_from_stats <- function(stats, formats_in = NULL) { #' variable names if rows correspond to different variables instead of levels. Defaults to `NULL`. #' #' @return -#' * `get_labels_from_stats()` returns a named character vector of default labels (if present -#' otherwise `NULL`). +#' * `get_labels_from_stats()` returns a named `character` vector of labels (if present in either +#' `tern_default_labels` or `labels_in`, otherwise `NULL`). #' #' @examples #' # Defaults labels @@ -306,7 +295,102 @@ get_indents_from_stats <- function(stats, indents_in = NULL, row_nms = NULL) { out } -#' @describeIn default_stats_formats_labels Named list of default formats for `tern`. +#' Update Labels According to Control Specifications +#' +#' @description `r lifecycle::badge("stable")` +#' +#' Given a list of statistic labels and and a list of control parameters, updates labels with a relevant +#' control specification. For example, if control has element `conf_level` set to `0.9`, the default +#' label for statistic `mean_ci` will be updated to `"Mean 90% CI"`. Any labels that are supplied +#' via `labels_custom` will not be updated regardless of `control`. +#' +#' @param labels_default (named `vector` of `character`)\cr a named vector of statistic labels to modify +#' according to the control specifications. Labels that are explicitly defined in `labels_custom` will +#' not be affected. +#' @param labels_custom (named `vector` of `character`)\cr named vector of labels that are customized by +#' the user and should not be affected by `control`. +#' @param control (named `list`)\cr list of control parameters to apply to adjust default labels. +#' +#' @return A named character vector of labels with control specifications applied to relevant labels. +#' +#' @examples +#' control <- list(conf_level = 0.80, quantiles = c(0.1, 0.83), test_mean = 0.57) +#' get_labels_from_stats(c("mean_ci", "quantiles", "mean_pval")) %>% +#' labels_apply_control(control = control) +#' +labels_apply_control <- function(labels_default, control, labels_custom = NULL) { + if ("conf_level" %in% names(control)) { + labels_default <- sapply( + names(labels_default), + function(x) { + if (!x %in% names(labels_custom)) { + gsub(labels_default[[x]], pattern = "[0-9]+% CI", replacement = f_conf_level(control[["conf_level"]])) + } else { + labels_default[[x]] + } + } + ) + } + if ("quantiles" %in% names(control) && !"quantiles" %in% names(labels_custom)) { + labels_default["quantiles"] <- gsub( + "[0-9]+% and [0-9]+", paste0(control[["quantiles"]][1] * 100, "% and ", control[["quantiles"]][2] * 100, ""), + labels_default["quantiles"] + ) + } + if ("test_mean" %in% names(control) && !"mean_pval" %in% names(labels_custom)) { + labels_default["mean_pval"] <- gsub( + "p-value \\(H0: mean = [0-9\\.]+\\)", f_pval(control[["test_mean"]]), labels_default["mean_pval"] + ) + } + + labels_default +} + +#' @describeIn default_stats_formats_labels Named list of available statistics by method group for `tern`. +#' +#' @format +#' * `tern_default_stats` is a named list of available statistics, with each element +#' named for their corresponding statistical method group. +#' +#' @export +tern_default_stats <- list( + abnormal = c("fraction"), + abnormal_by_baseline = c("fraction"), + abnormal_by_marked = c("count_fraction"), + abnormal_by_worst_grade = c("count_fraction"), + abnormal_by_worst_grade_worsen = c("fraction"), + analyze_patients_exposure_in_cols = c("n_patients", "sum_exposure"), + analyze_vars_counts = c("n", "count", "count_fraction", "n_blq"), + analyze_vars_numeric = c( + "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", "mean_sdi", "mean_pval", + "median", "mad", "median_ci", "quantiles", "iqr", "range", "min", "max", "median_range", "cv", + "geom_mean", "geom_mean_ci", "geom_cv" + ), + count_cumulative = c("count_fraction"), + count_missed_doses = c("n", "count_fraction"), + count_occurrences = c("count", "count_fraction", "count_fraction_fixed_dp", "fraction"), + count_occurrences_by_grade = c("count_fraction"), + count_patients_with_event = c("n", "count", "count_fraction", "n_blq"), + count_patients_with_flags = c("n", "count", "count_fraction", "n_blq"), + count_values = c("n", "count", "count_fraction", "n_blq"), + coxph_pairwise = c("pvalue", "hr", "hr_ci", "n_tot", "n_tot_events"), + estimate_incidence_rate = c("person_years", "n_events", "rate", "rate_ci"), + estimate_multinomial_response = c("n_prop", "prop_ci"), + estimate_odds_ratio = c("or_ci", "n_tot"), + estimate_proportion = c("n_prop", "prop_ci"), + estimate_proportion_diff = c("diff", "diff_ci"), + summarize_ancova = c("n", "lsmean", "lsmean_diff", "lsmean_diff_ci", "pval"), + summarize_coxreg = c("n", "hr", "ci", "pval", "pval_inter"), + summarize_glm_count = c("n", "rate", "rate_ci", "rate_ratio", "rate_ratio_ci", "pval"), + summarize_num_patients = c("unique", "nonunique", "unique_count"), + summarize_patients_events_in_cols = c("unique", "all"), + surv_time = c("median", "median_ci", "quantiles", "range_censor", "range_event", "range"), + surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), + test_proportion_diff = c("pval") +) + +#' @describeIn default_stats_formats_labels Named vector of default formats for `tern`. +#' #' @format #' * `tern_default_formats` is a list of available formats, named after their relevant #' statistic. diff --git a/man/default_stats_formats_labels.Rd b/man/default_stats_formats_labels.Rd index 84997cbde5..ab40c29664 100644 --- a/man/default_stats_formats_labels.Rd +++ b/man/default_stats_formats_labels.Rd @@ -7,16 +7,22 @@ \alias{get_formats_from_stats} \alias{get_labels_from_stats} \alias{get_indents_from_stats} +\alias{tern_default_stats} \alias{tern_default_formats} \alias{tern_default_labels} \alias{summary_formats} \alias{summary_labels} \alias{summary_custom} -\title{Defaults for statistical method names and their associated formats & labels} +\title{Get default statistical methods and their associated formats, labels, and indent modifiers} \format{ \itemize{ -\item \code{tern_default_formats} is a list of available formats, named after their relevant -statistic. +\item \code{tern_default_stats} is a named list of available statistics, with each element +named for their corresponding statistical method group. +} + +\itemize{ +\item \code{tern_default_formats} is a named vector of available default formats, with each element +named for their corresponding statistic. } \itemize{ @@ -37,6 +43,8 @@ get_labels_from_stats(stats, labels_in = NULL, row_nms = NULL) get_indents_from_stats(stats, indents_in = NULL, row_nms = NULL) +tern_default_stats + tern_default_formats tern_default_labels @@ -55,21 +63,19 @@ summary_custom( ) } \arguments{ -\item{method_groups}{(\code{character})\cr indicates the group of statistical methods that -we need the defaults from. A character vector can be used to collect more than one group of statistical -methods.} +\item{method_groups}{(\code{character})\cr indicates the statistical method group (\code{tern} analyze function) +to retrieve default statistics for. A character vector can be used to specify more than one statistical +method group.} -\item{stats_in}{(\code{character})\cr desired stats to be picked out from the selected method group.} +\item{stats_in}{(\code{character})\cr statistics to retrieve for the selected method group.} -\item{add_pval}{(\code{flag})\cr should \code{"pval"} or \code{"pval_counts"} (if \code{method_groups} contains +\item{add_pval}{(\code{flag})\cr should \code{"pval"} (or \code{"pval_counts"} if \code{method_groups} contains \code{"analyze_vars_counts"}) be added to the statistical methods?} -\item{stats}{(\code{character})\cr statistical methods to get defaults formats or labels for.} - \item{formats_in}{(named \code{vector}) \cr inserted formats to replace defaults. It can be a character vector from \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} or a custom format function.} -\item{labels_in}{(named \code{vector})\cr inserted labels to replace defaults.} +\item{labels_in}{(named \code{vector} of \code{character})\cr inserted labels to replace defaults.} \item{row_nms}{(\code{character})\cr row names. Levels of a \code{factor} or \code{character} variable, each of which the statistics in \code{.stats} will be calculated for. If this parameter is set, these @@ -103,17 +109,18 @@ statistics by setting \code{indent_mods_custom} to a single integer value.} } \value{ \itemize{ -\item \code{get_stats()} returns a character vector with all default statistical methods. +\item \code{get_stats()} returns a \code{character} vector of statistical methods. } \itemize{ -\item \code{get_formats_from_stats()} returns a named list of formats, they being a value from +\item \code{get_formats_from_stats()} returns a named vector of formats (if present in either +\code{tern_default_formats} or \code{formats_in}, otherwise \code{NULL}). Values can be taken from \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} or a custom function (e.g. \link{formatting_functions}). } \itemize{ -\item \code{get_labels_from_stats()} returns a named character vector of default labels (if present -otherwise \code{NULL}). +\item \code{get_labels_from_stats()} returns a named \code{character} vector of labels (if present in either +\code{tern_default_labels} or \code{labels_in}, otherwise \code{NULL}). } \itemize{ @@ -138,26 +145,27 @@ and \code{indent_mods}. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} Utility functions to get valid statistic methods for different method groups -(\code{.stats}) and their associated formats (\code{.formats}) and labels (\code{.labels}). This utility -is used across \code{tern}, but some of its working principles can be seen in \code{\link[=analyze_vars]{analyze_vars()}}. -See notes to understand why this is experimental. +(\code{.stats}) and their associated formats (\code{.formats}), labels (\code{.labels}), and indent modifiers +(\code{.indent_mods}). This utility is used across \code{tern}, but some of its working principles can be +seen in \code{\link[=analyze_vars]{analyze_vars()}}. See notes to understand why this is experimental. } \details{ Current choices for \code{type} are \code{counts} and \code{numeric} for \code{\link[=analyze_vars]{analyze_vars()}} and affect \code{get_stats()}. } \section{Functions}{ \itemize{ -\item \code{get_stats()}: Get defaults statistical methods for different -groups of methods. +\item \code{get_stats()}: Get statistics available for a given method +group (analyze function). -\item \code{get_formats_from_stats()}: Get formats from vector of statistical methods. If not -present \code{NULL} is returned. +\item \code{get_formats_from_stats()}: Get formats corresponding to a list of statistics. -\item \code{get_labels_from_stats()}: Get labels from vector of statistical methods. +\item \code{get_labels_from_stats()}: Get labels corresponding to a list of statistics. \item \code{get_indents_from_stats()}: Format indent modifiers for a given vector/list of statistics. -\item \code{tern_default_formats}: Named list of default formats for \code{tern}. +\item \code{tern_default_stats}: Named list of available statistics by method group for \code{tern}. + +\item \code{tern_default_formats}: Named vector of default formats for \code{tern}. \item \code{tern_default_labels}: \code{character} vector that contains default labels for \code{tern}. From caef29e215d1c4f304b0908ea289a5dbfa3036cc Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 17:00:24 -0400 Subject: [PATCH 02/16] Update NAMESPACE --- NAMESPACE | 1 + 1 file changed, 1 insertion(+) diff --git a/NAMESPACE b/NAMESPACE index c6396b4d69..6bcc4bb4b7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -287,6 +287,7 @@ export(tabulate_survival_biomarkers) export(tabulate_survival_subgroups) export(tern_default_formats) export(tern_default_labels) +export(tern_default_stats) export(test_proportion_diff) export(to_n) export(to_string_matrix) From 6fb59af3b8ff36e62338a707a6b9bc8ad7c6fc42 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 17:01:47 -0400 Subject: [PATCH 03/16] Remove control function --- R/utils_default_stats_formats_labels.R | 51 -------------------------- 1 file changed, 51 deletions(-) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 88d7aa8c5a..f311c52323 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -295,57 +295,6 @@ get_indents_from_stats <- function(stats, indents_in = NULL, row_nms = NULL) { out } -#' Update Labels According to Control Specifications -#' -#' @description `r lifecycle::badge("stable")` -#' -#' Given a list of statistic labels and and a list of control parameters, updates labels with a relevant -#' control specification. For example, if control has element `conf_level` set to `0.9`, the default -#' label for statistic `mean_ci` will be updated to `"Mean 90% CI"`. Any labels that are supplied -#' via `labels_custom` will not be updated regardless of `control`. -#' -#' @param labels_default (named `vector` of `character`)\cr a named vector of statistic labels to modify -#' according to the control specifications. Labels that are explicitly defined in `labels_custom` will -#' not be affected. -#' @param labels_custom (named `vector` of `character`)\cr named vector of labels that are customized by -#' the user and should not be affected by `control`. -#' @param control (named `list`)\cr list of control parameters to apply to adjust default labels. -#' -#' @return A named character vector of labels with control specifications applied to relevant labels. -#' -#' @examples -#' control <- list(conf_level = 0.80, quantiles = c(0.1, 0.83), test_mean = 0.57) -#' get_labels_from_stats(c("mean_ci", "quantiles", "mean_pval")) %>% -#' labels_apply_control(control = control) -#' -labels_apply_control <- function(labels_default, control, labels_custom = NULL) { - if ("conf_level" %in% names(control)) { - labels_default <- sapply( - names(labels_default), - function(x) { - if (!x %in% names(labels_custom)) { - gsub(labels_default[[x]], pattern = "[0-9]+% CI", replacement = f_conf_level(control[["conf_level"]])) - } else { - labels_default[[x]] - } - } - ) - } - if ("quantiles" %in% names(control) && !"quantiles" %in% names(labels_custom)) { - labels_default["quantiles"] <- gsub( - "[0-9]+% and [0-9]+", paste0(control[["quantiles"]][1] * 100, "% and ", control[["quantiles"]][2] * 100, ""), - labels_default["quantiles"] - ) - } - if ("test_mean" %in% names(control) && !"mean_pval" %in% names(labels_custom)) { - labels_default["mean_pval"] <- gsub( - "p-value \\(H0: mean = [0-9\\.]+\\)", f_pval(control[["test_mean"]]), labels_default["mean_pval"] - ) - } - - labels_default -} - #' @describeIn default_stats_formats_labels Named list of available statistics by method group for `tern`. #' #' @format From 6636eb1792c9f11d8cac308ae2436b67354683c7 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 18:01:33 -0400 Subject: [PATCH 04/16] Update NEWS --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index bd197f3432..2030b40e85 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Added `ref_group_position` function to place the reference group facet last, first or at a certain position. * Added `keep_level_order` split function to retain original order of levels in a split. * Added `level_order` split function to reorder manually the levels. +* Added list containing default statistics for each method group, `tern_default_stats`. ### Enhancements * Added `ref_group_coxph` parameter to `g_km` to specify the reference group used for pairwise Cox-PH calculations when `annot_coxph = TRUE`. From 2dd73c34e198bef4e6aa5ea44da0dcb3fc9f400d Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 18:08:25 -0400 Subject: [PATCH 05/16] Refactor switcher --- R/utils_default_stats_formats_labels.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index f311c52323..47861a1878 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -64,12 +64,11 @@ get_stats <- function(method_groups = "analyze_vars_numeric", stats_in = NULL, a # Loop for multiple method groups for (mgi in method_groups) { - # Main switcher - out_tmp <- switch( - mgi, - tern_default_stats, + out_tmp <- if (mgi %in% names(tern_default_stats)) { + tern_default_stats[[mgi]] + } else { stop("The selected method group (", mgi, ") has no default statistical method.") - ) + } out <- unique(c(out, out_tmp)) } From 19b7ead7808340137ecc9decec1679fdff644766 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:12:06 +0000 Subject: [PATCH 06/16] [skip actions] Roxygen Man Pages Auto Update --- man/default_stats_formats_labels.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/default_stats_formats_labels.Rd b/man/default_stats_formats_labels.Rd index ab40c29664..f336c14791 100644 --- a/man/default_stats_formats_labels.Rd +++ b/man/default_stats_formats_labels.Rd @@ -21,8 +21,8 @@ named for their corresponding statistical method group. } \itemize{ -\item \code{tern_default_formats} is a named vector of available default formats, with each element -named for their corresponding statistic. +\item \code{tern_default_formats} is a list of available formats, named after their relevant +statistic. } \itemize{ From d30659a585027e6ed42c40c0a0c10fd7676b96a5 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 18:19:51 -0400 Subject: [PATCH 07/16] Empty commit From c96d0e916bd0a8916bd3ef29784e4dcd6be50bc7 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Thu, 2 Nov 2023 18:37:13 -0400 Subject: [PATCH 08/16] Fix docs --- R/utils_default_stats_formats_labels.R | 2 ++ man/default_stats_formats_labels.Rd | 2 ++ 2 files changed, 4 insertions(+) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 47861a1878..3c30dcc7bb 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -7,6 +7,8 @@ #' (`.indent_mods`). 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 for. +#' #' @details #' Current choices for `type` are `counts` and `numeric` for [analyze_vars()] and affect `get_stats()`. #' diff --git a/man/default_stats_formats_labels.Rd b/man/default_stats_formats_labels.Rd index f336c14791..e8dd196eb9 100644 --- a/man/default_stats_formats_labels.Rd +++ b/man/default_stats_formats_labels.Rd @@ -72,6 +72,8 @@ method group.} \item{add_pval}{(\code{flag})\cr should \code{"pval"} (or \code{"pval_counts"} if \code{method_groups} contains \code{"analyze_vars_counts"}) be added to the statistical methods?} +\item{stats}{(\code{character})\cr statistical methods to get defaults for.} + \item{formats_in}{(named \code{vector}) \cr inserted formats to replace defaults. It can be a character vector from \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} or a custom format function.} From a173ff97cf3298572e1a00dfaa9da34e813b21e0 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 15:26:05 -0500 Subject: [PATCH 09/16] Add "count_fraction_fixed_dp" for all methods that allow "count_fraction" --- R/utils_default_stats_formats_labels.R | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 3c30dcc7bb..00b72c35bf 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -306,23 +306,23 @@ get_indents_from_stats <- function(stats, indents_in = NULL, row_nms = NULL) { tern_default_stats <- list( abnormal = c("fraction"), abnormal_by_baseline = c("fraction"), - abnormal_by_marked = c("count_fraction"), - abnormal_by_worst_grade = c("count_fraction"), + abnormal_by_marked = c("count_fraction", "count_fraction_fixed_dp"), + abnormal_by_worst_grade = c("count_fraction", "count_fraction_fixed_dp"), abnormal_by_worst_grade_worsen = c("fraction"), analyze_patients_exposure_in_cols = c("n_patients", "sum_exposure"), - analyze_vars_counts = c("n", "count", "count_fraction", "n_blq"), + analyze_vars_counts = c("n", "count", "count_fraction", "count_fraction_fixed_dp", "n_blq"), analyze_vars_numeric = c( "n", "sum", "mean", "sd", "se", "mean_sd", "mean_se", "mean_ci", "mean_sei", "mean_sdi", "mean_pval", "median", "mad", "median_ci", "quantiles", "iqr", "range", "min", "max", "median_range", "cv", "geom_mean", "geom_mean_ci", "geom_cv" ), - count_cumulative = c("count_fraction"), - count_missed_doses = c("n", "count_fraction"), + count_cumulative = c("count_fraction", "count_fraction_fixed_dp"), + count_missed_doses = c("n", "count_fraction", "count_fraction_fixed_dp"), count_occurrences = c("count", "count_fraction", "count_fraction_fixed_dp", "fraction"), - count_occurrences_by_grade = c("count_fraction"), - count_patients_with_event = c("n", "count", "count_fraction", "n_blq"), - count_patients_with_flags = c("n", "count", "count_fraction", "n_blq"), - count_values = c("n", "count", "count_fraction", "n_blq"), + count_occurrences_by_grade = c("count_fraction", "count_fraction_fixed_dp"), + count_patients_with_event = c("n", "count", "count_fraction", "count_fraction_fixed_dp", "n_blq"), + count_patients_with_flags = c("n", "count", "count_fraction", "count_fraction_fixed_dp", "n_blq"), + count_values = c("n", "count", "count_fraction", "count_fraction_fixed_dp", "n_blq"), coxph_pairwise = c("pvalue", "hr", "hr_ci", "n_tot", "n_tot_events"), estimate_incidence_rate = c("person_years", "n_events", "rate", "rate_ci"), estimate_multinomial_response = c("n_prop", "prop_ci"), From 4e81efd55fb6a77a2c811fc3e2cf77f798612575 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 16:36:16 -0500 Subject: [PATCH 10/16] Deprecate `vars` argument in tabulate functions to replace with `.stats` --- NEWS.md | 1 + R/response_biomarkers_subgroups.R | 10 ++++++++-- R/response_subgroups.R | 10 ++++++++-- R/survival_biomarkers_subgroups.R | 10 ++++++++-- R/survival_duration_subgroups.R | 10 ++++++++-- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 820eaa5ba7..87d9c9a7c0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ ### Miscellaneous * Specified minimal version of package dependencies. +* Began deprecation of `vars` argument in `tabulate_rsp_biomarkers`, `tabulate_rsp_subgroups`, `tabulate_survival_biomarkers`, and `tabulate_survival_subgroups` and replaced it with the `.stats` argument. # tern 0.9.2 diff --git a/R/response_biomarkers_subgroups.R b/R/response_biomarkers_subgroups.R index e66fc32f4e..37259a072e 100644 --- a/R/response_biomarkers_subgroups.R +++ b/R/response_biomarkers_subgroups.R @@ -8,7 +8,7 @@ #' @inheritParams argument_convention #' @param df (`data.frame`)\cr containing all analysis variables, as returned by #' [extract_rsp_biomarkers()]. -#' @param vars (`character`)\cr the names of statistics to be reported among: +#' @param .stats (`character`)\cr the names of statistics to be reported among: #' * `n_tot`: Total number of patients per group. #' * `n_rsp`: Total number of responses per group. #' * `prop`: Total response proportion per group. @@ -67,8 +67,14 @@ #' @export #' @name response_biomarkers_subgroups tabulate_rsp_biomarkers <- function(df, - vars = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), + vars = lifecycle::deprecated(), + .stats = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), .indent_mods = 0L) { + if (lifecycle::is_present(vars)) { + lifecycle::deprecate_warn("0.9.3", "tabulate_rsp_biomarkers(vars)", "tabulate_rsp_biomarkers(.stats)") + .stats <- vars + } + checkmate::assert_data_frame(df) checkmate::assert_character(df$biomarker) checkmate::assert_character(df$biomarker_label) diff --git a/R/response_subgroups.R b/R/response_subgroups.R index e194b1542d..7ea3c467bc 100644 --- a/R/response_subgroups.R +++ b/R/response_subgroups.R @@ -178,7 +178,7 @@ a_response_subgroups <- function(.formats = list( #' #' @param df (`list`)\cr of data frames containing all analysis variables. List should be #' created using [extract_rsp_subgroups()]. -#' @param vars (`character`)\cr the names of statistics to be reported among: +#' @param .stats (`character`)\cr the names of statistics to be reported among: #' * `n`: Total number of observations per group. #' * `n_rsp`: Number of responders per group. #' * `prop`: Proportion of responders. @@ -205,7 +205,13 @@ a_response_subgroups <- function(.formats = list( #' @export tabulate_rsp_subgroups <- function(lyt, df, - vars = c("n_tot", "n", "prop", "or", "ci")) { + vars = lifecycle::deprecated(), + .stats = c("n_tot", "n", "prop", "or", "ci")) { + if (lifecycle::is_present(vars)) { + lifecycle::deprecate_warn("0.9.3", "tabulate_rsp_subgroups(vars)", "tabulate_rsp_subgroups(.stats)") + .stats <- vars + } + conf_level <- df$or$conf_level[1] method <- if ("pval_label" %in% names(df$or)) { df$or$pval_label[1] diff --git a/R/survival_biomarkers_subgroups.R b/R/survival_biomarkers_subgroups.R index b3bfc67ed7..6bef780835 100644 --- a/R/survival_biomarkers_subgroups.R +++ b/R/survival_biomarkers_subgroups.R @@ -172,7 +172,7 @@ extract_survival_biomarkers <- function(variables, #' #' @param df (`data.frame`)\cr containing all analysis variables, as returned by #' [extract_survival_biomarkers()]. -#' @param vars (`character`)\cr the names of statistics to be reported among: +#' @param .stats (`character`)\cr the names of statistics to be reported among: #' * `n_tot_events`: Total number of events per group. #' * `n_tot`: Total number of observations per group. #' * `median`: Median survival time. @@ -207,9 +207,15 @@ extract_survival_biomarkers <- function(variables, #' #' @export tabulate_survival_biomarkers <- function(df, - vars = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), + vars = lifecycle::deprecated(), time_unit = NULL, + .stats = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), .indent_mods = 0L) { + if (lifecycle::is_present(vars)) { + lifecycle::deprecate_warn("0.9.3", "tabulate_survival_biomarkers(vars)", "tabulate_survival_biomarkers(.stats)") + .stats <- vars + } + checkmate::assert_data_frame(df) checkmate::assert_character(df$biomarker) checkmate::assert_character(df$biomarker_label) diff --git a/R/survival_duration_subgroups.R b/R/survival_duration_subgroups.R index 4f50bd466c..2a4f2a365d 100644 --- a/R/survival_duration_subgroups.R +++ b/R/survival_duration_subgroups.R @@ -212,7 +212,7 @@ a_survival_subgroups <- function(.formats = list( # nolint start #' #' @param df (`list`)\cr of data frames containing all analysis variables. List should be #' created using [extract_survival_subgroups()]. -#' @param vars (`character`)\cr the name of statistics to be reported among: +#' @param .stats (`character`)\cr the name of statistics to be reported among: #' * `n_tot_events`: Total number of events per group. #' * `n_events`: Number of events per group. #' * `n_tot`: Total number of observations per group. @@ -242,9 +242,15 @@ a_survival_subgroups <- function(.formats = list( # nolint start #' @export tabulate_survival_subgroups <- function(lyt, df, - vars = c("n_tot_events", "n_events", "median", "hr", "ci"), + vars = lifecycle::deprecated(), time_unit = NULL, + .stats = c("n_tot_events", "n_events", "median", "hr", "ci"), na_str = NA_character_) { + if (lifecycle::is_present(vars)) { + lifecycle::deprecate_warn("0.9.3", "tabulate_survival_subgroups(vars)", "tabulate_survival_subgroups(.stats)") + .stats <- vars + } + conf_level <- df$hr$conf_level[1] method <- df$hr$pval_label[1] From ce083dcc78a1e074609138bd77e850ede8a95548 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 16:37:29 -0500 Subject: [PATCH 11/16] Add `get_stats` calls to `.stats` param descriptions --- R/abnormal.R | 2 ++ R/abnormal_by_baseline.R | 2 ++ R/abnormal_by_marked.R | 2 ++ R/abnormal_by_worst_grade.R | 2 ++ R/abnormal_by_worst_grade_worsen.R | 2 ++ R/analyze_variables.R | 4 +++- R/count_cumulative.R | 2 ++ R/count_missed_doses.R | 2 ++ R/count_occurrences.R | 2 ++ R/count_occurrences_by_grade.R | 2 ++ R/count_patients_events_in_cols.R | 3 +++ R/count_patients_with_event.R | 2 ++ R/count_patients_with_flags.R | 2 ++ R/count_values.R | 2 ++ R/estimate_multinomial_rsp.R | 2 ++ R/estimate_proportion.R | 2 ++ R/incidence_rate.R | 2 ++ R/odds_ratio.R | 2 ++ R/prop_diff.R | 2 ++ R/prop_diff_test.R | 2 ++ R/response_biomarkers_subgroups.R | 2 +- R/summarize_ancova.R | 2 ++ R/summarize_change.R | 2 ++ R/summarize_coxreg.R | 2 ++ R/summarize_glm_count.R | 2 ++ R/summarize_num_patients.R | 2 ++ R/summarize_patients_exposure_in_cols.R | 2 ++ R/survival_biomarkers_subgroups.R | 2 +- R/survival_coxph_pairwise.R | 2 ++ R/survival_time.R | 2 ++ R/survival_timepoint.R | 2 ++ R/utils_default_stats_formats_labels.R | 4 ++++ 32 files changed, 66 insertions(+), 3 deletions(-) diff --git a/R/abnormal.R b/R/abnormal.R index ec337dd3ee..947fd93d59 100644 --- a/R/abnormal.R +++ b/R/abnormal.R @@ -13,6 +13,8 @@ #' @param abnormal (named `list`)\cr list identifying the abnormal range level(s) in `var`. Defaults to #' `list(Low = "LOW", High = "HIGH")` but you can also group different levels into the named list, #' for example, `abnormal = list(Low = c("LOW", "LOW LOW"), High = c("HIGH", "HIGH HIGH"))`. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("abnormal")` +#' to see available statistics for this function. #' #' @note #' * `count_abnormal()` only works with a single variable containing multiple abnormal levels. diff --git a/R/abnormal_by_baseline.R b/R/abnormal_by_baseline.R index b308a74162..191e1e8bec 100644 --- a/R/abnormal_by_baseline.R +++ b/R/abnormal_by_baseline.R @@ -18,6 +18,8 @@ #' #' @inheritParams argument_convention #' @param abnormal (`character`)\cr identifying the abnormal range level(s) in `.var`. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("abnormal_by_baseline")` +#' to see available statistics for this function. #' #' @note #' * `df` should be filtered to include only post-baseline records. diff --git a/R/abnormal_by_marked.R b/R/abnormal_by_marked.R index ffcaee38ba..c2bf670215 100644 --- a/R/abnormal_by_marked.R +++ b/R/abnormal_by_marked.R @@ -14,6 +14,8 @@ #' @inheritParams argument_convention #' @param category (`list`)\cr with different marked category names for single #' and last or replicated. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("abnormal_by_marked")` +#' to see available statistics for this function. #' #' @note `Single, not last` and `Last or replicated` levels are mutually exclusive. If a patient has #' abnormalities that meet both the `Single, not last` and `Last or replicated` criteria, then the diff --git a/R/abnormal_by_worst_grade.R b/R/abnormal_by_worst_grade.R index d6f7ee59fc..e4deb22784 100644 --- a/R/abnormal_by_worst_grade.R +++ b/R/abnormal_by_worst_grade.R @@ -12,6 +12,8 @@ #' * `Any`: Numerator is number of patients with at least one abnormality, which means grade is different from 0. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("abnormal_by_worst_grade")` +#' to see available statistics for this function. #' #' @details The pre-processing steps are crucial when using this function. From the standard lab grade variable #' `ATOXGR`, derive the following two variables: diff --git a/R/abnormal_by_worst_grade_worsen.R b/R/abnormal_by_worst_grade_worsen.R index 120dc107a2..8c47944ce7 100644 --- a/R/abnormal_by_worst_grade_worsen.R +++ b/R/abnormal_by_worst_grade_worsen.R @@ -5,6 +5,8 @@ #' Patient count and fraction for laboratory events (worsen from baseline) shift table. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("abnormal_by_worst_grade_worsen")` +#' to see all available statistics. #' #' @seealso Relevant helper functions [h_adlb_worsen()] and [h_worsen_counter()] #' diff --git a/R/analyze_variables.R b/R/analyze_variables.R index b44e4c16a5..0ca9abee55 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -46,6 +46,9 @@ control_summarize_vars <- control_analyze_vars #' functions; in this case [rtables::analyze()]. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("analyze_vars_numeric")` to see +#' statistics available for numeric variables, and `get_stats("analyze_vars_counts")` for statistics available +#' for non-numeric variables. #' #' @name analyze_variables NULL @@ -454,7 +457,6 @@ s_summary.logical <- function(x, #' a_summary(rnorm(10), .N_col = 10, .N_row = 20, .var = "bla") #' a_summary(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .var = "bla", compare = TRUE) #' - #' @export a_summary <- function(x, .N_col, # nolint diff --git a/R/count_cumulative.R b/R/count_cumulative.R index 4f94ba5d86..3928560dab 100644 --- a/R/count_cumulative.R +++ b/R/count_cumulative.R @@ -7,6 +7,8 @@ #' #' @inheritParams h_count_cumulative #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_cumulative")` +#' to see available statistics for this function. #' #' @seealso Relevant helper function [h_count_cumulative()], and descriptive function [d_count_cumulative()]. #' diff --git a/R/count_missed_doses.R b/R/count_missed_doses.R index 735acb5460..55f57dcd9f 100644 --- a/R/count_missed_doses.R +++ b/R/count_missed_doses.R @@ -6,6 +6,8 @@ #' mainly the special labels. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_missed_doses")` +#' to see available statistics for this function. #' #' @seealso Relevant description function [d_count_missed_doses()]. #' diff --git a/R/count_occurrences.R b/R/count_occurrences.R index 677458f416..09b9873ccd 100644 --- a/R/count_occurrences.R +++ b/R/count_occurrences.R @@ -8,6 +8,8 @@ #' counted only once. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_occurrences")` +#' to see available statistics for this function. #' #' @note By default, occurrences which don't appear in a given row split are dropped from the table and #' the occurrences in the table are sorted alphabetically per row split. Therefore, the corresponding layout diff --git a/R/count_occurrences_by_grade.R b/R/count_occurrences_by_grade.R index 9b67fc7278..785aff4256 100644 --- a/R/count_occurrences_by_grade.R +++ b/R/count_occurrences_by_grade.R @@ -10,6 +10,8 @@ #' @param grade_groups (named `list` of `character`)\cr containing groupings of grades. #' @param remove_single (`logical`)\cr `TRUE` to not include the elements of one-element grade groups #' in the the output list; in this case only the grade groups names will be included in the output. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_occurrences_by_grade")` +#' to see available statistics for this function. #' #' @seealso Relevant helper function [h_append_grade_groups()]. #' diff --git a/R/count_patients_events_in_cols.R b/R/count_patients_events_in_cols.R index 5eb601aaf4..135e0018d4 100644 --- a/R/count_patients_events_in_cols.R +++ b/R/count_patients_events_in_cols.R @@ -6,6 +6,9 @@ #' when a column table layout is required. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run +#' `get_stats("summarize_patients_events_in_cols")` to see available statistics for this function, in addition to any +#' added using `filters_list`. #' #' @name count_patients_events_in_cols NULL diff --git a/R/count_patients_with_event.R b/R/count_patients_with_event.R index 92cc42edba..9b6d1bc91e 100644 --- a/R/count_patients_with_event.R +++ b/R/count_patients_with_event.R @@ -5,6 +5,8 @@ #' The primary analysis variable `.var` denotes the unique patient identifier. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_patients_with_event")` +#' to see available statistics for this function. #' #' @seealso [count_patients_with_flags] #' diff --git a/R/count_patients_with_flags.R b/R/count_patients_with_flags.R index e7580b34cf..1b3edf3354 100644 --- a/R/count_patients_with_flags.R +++ b/R/count_patients_with_flags.R @@ -5,6 +5,8 @@ #' The primary analysis variable `.var` denotes the unique patient identifier. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_patients_with_flags")` +#' to see available statistics for this function. #' #' @seealso [count_patients_with_event] #' diff --git a/R/count_values.R b/R/count_values.R index ebbf8068dd..428e80159a 100644 --- a/R/count_values.R +++ b/R/count_values.R @@ -5,6 +5,8 @@ #' We can count the occurrence of specific values in a variable of interest. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("count_values")` +#' to see available statistics for this function. #' #' @note #' * For `factor` variables, `s_count_values` checks whether `values` are all included in the levels of `x` diff --git a/R/estimate_multinomial_rsp.R b/R/estimate_multinomial_rsp.R index fb3fafff16..5c003ffd26 100644 --- a/R/estimate_multinomial_rsp.R +++ b/R/estimate_multinomial_rsp.R @@ -6,6 +6,8 @@ #' regarding the level of a factor. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("estimate_multinomial_response")` +#' to see available statistics for this function. #' #' @seealso Relevant description function [d_onco_rsp_label()]. #' diff --git a/R/estimate_proportion.R b/R/estimate_proportion.R index d7d88f1525..8552aaab8d 100644 --- a/R/estimate_proportion.R +++ b/R/estimate_proportion.R @@ -5,6 +5,8 @@ #' Estimate the proportion of responders within a studied population. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("estimate_proportion")` +#' to see available statistics for this function. #' #' @seealso [h_proportions] #' diff --git a/R/incidence_rate.R b/R/incidence_rate.R index ddf0410ebc..91c8946021 100644 --- a/R/incidence_rate.R +++ b/R/incidence_rate.R @@ -15,6 +15,8 @@ #' indicating time unit for data input. #' * `num_pt_year` (`numeric`)\cr time unit for desired output (in person-years). #' @param n_events (`integer`)\cr number of events observed. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("estimate_incidence_rate")` +#' to see available statistics for this function. #' #' @seealso [control_incidence_rate()] and helper functions [h_incidence_rate]. #' diff --git a/R/odds_ratio.R b/R/odds_ratio.R index dac3c1cba7..cc9ea9754f 100644 --- a/R/odds_ratio.R +++ b/R/odds_ratio.R @@ -6,6 +6,8 @@ #' along with a confidence interval. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("estimate_odds_ratio")` +#' to see available statistics for this function. #' #' @details This function uses either logistic regression for unstratified #' analyses, or conditional logistic regression for stratified analyses. diff --git a/R/prop_diff.R b/R/prop_diff.R index 27a27c8c06..b82ac4ff1a 100644 --- a/R/prop_diff.R +++ b/R/prop_diff.R @@ -3,6 +3,8 @@ #' @description `r lifecycle::badge("stable")` #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("estimate_proportion_diff")` +#' to see available statistics for this function. #' #' @seealso [d_proportion_diff()] #' diff --git a/R/prop_diff_test.R b/R/prop_diff_test.R index c8b65343f9..2f77dfabd5 100644 --- a/R/prop_diff_test.R +++ b/R/prop_diff_test.R @@ -5,6 +5,8 @@ #' Various tests were implemented to test the difference between two proportions. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("test_proportion_diff")` +#' to see available statistics for this function. #' #' @seealso [h_prop_diff_test] #' diff --git a/R/response_biomarkers_subgroups.R b/R/response_biomarkers_subgroups.R index 37259a072e..ca87a298b4 100644 --- a/R/response_biomarkers_subgroups.R +++ b/R/response_biomarkers_subgroups.R @@ -78,7 +78,7 @@ tabulate_rsp_biomarkers <- function(df, checkmate::assert_data_frame(df) checkmate::assert_character(df$biomarker) checkmate::assert_character(df$biomarker_label) - checkmate::assert_subset(vars, c("n_tot", "n_rsp", "prop", "or", "ci", "pval")) + checkmate::assert_subset(vars, get_stats("tabulate_rsp_biomarkers")) df_subs <- split(df, f = df$biomarker) tabs <- lapply(df_subs, FUN = function(df_sub) { diff --git a/R/summarize_ancova.R b/R/summarize_ancova.R index 8af0627940..6033c88aa9 100644 --- a/R/summarize_ancova.R +++ b/R/summarize_ancova.R @@ -6,6 +6,8 @@ #' multiple timepoints within the same response variable `.var`. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("summarize_ancova")` +#' to see available statistics for this function. #' #' @name summarize_ancova NULL diff --git a/R/summarize_change.R b/R/summarize_change.R index 0c3d66a217..a57c9a46aa 100644 --- a/R/summarize_change.R +++ b/R/summarize_change.R @@ -8,6 +8,8 @@ #' or the change from baseline values (post-baseline) are then summarized. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("analyze_vars_numeric)` +#' to see available statistics for this function. #' #' @name summarize_change NULL diff --git a/R/summarize_coxreg.R b/R/summarize_coxreg.R index 0e19cdb554..a0f112c935 100644 --- a/R/summarize_coxreg.R +++ b/R/summarize_coxreg.R @@ -5,6 +5,8 @@ #' Fits a Cox regression model and estimates hazard ratio to describe the effect size in a survival analysis. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("summarize_coxreg")` +#' to see available statistics for this function. #' #' @details Cox models are the most commonly used methods to estimate the magnitude of #' the effect in survival analysis. It assumes proportional hazards: the ratio diff --git a/R/summarize_glm_count.R b/R/summarize_glm_count.R index ca6544e950..2d03024d53 100644 --- a/R/summarize_glm_count.R +++ b/R/summarize_glm_count.R @@ -6,6 +6,8 @@ #' This can be used to analyze count and/or frequency data using a linear model. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("summarize_glm_count")` +#' to see available statistics for this function. #' #' @name summarize_glm_count NULL diff --git a/R/summarize_num_patients.R b/R/summarize_num_patients.R index 8883eb2f1b..01f3644d28 100644 --- a/R/summarize_num_patients.R +++ b/R/summarize_num_patients.R @@ -10,6 +10,8 @@ #' `nonunique` records. #' @param unique_count_suffix (`logical`)\cr should `"(n)"` suffix be added to `unique_count` labels. #' Defaults to `TRUE`. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("summarize_num_patients")` +#' to see available statistics for this function. #' #' @name summarize_num_patients NULL diff --git a/R/summarize_patients_exposure_in_cols.R b/R/summarize_patients_exposure_in_cols.R index d83672db3a..5ad66ba14d 100644 --- a/R/summarize_patients_exposure_in_cols.R +++ b/R/summarize_patients_exposure_in_cols.R @@ -6,6 +6,8 @@ #' when a column table layout is required. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run +#' `get_stats("analyze_patients_exposure_in_cols")` to see available statistics for this function. #' #' @name summarize_patients_exposure_in_cols NULL diff --git a/R/survival_biomarkers_subgroups.R b/R/survival_biomarkers_subgroups.R index 6bef780835..c14184b5ff 100644 --- a/R/survival_biomarkers_subgroups.R +++ b/R/survival_biomarkers_subgroups.R @@ -219,7 +219,7 @@ tabulate_survival_biomarkers <- function(df, checkmate::assert_data_frame(df) checkmate::assert_character(df$biomarker) checkmate::assert_character(df$biomarker_label) - checkmate::assert_subset(vars, c("n_tot", "n_tot_events", "median", "hr", "ci", "pval")) + checkmate::assert_subset(vars, get_stats("tabulate_survival_biomarkers")) df_subs <- split(df, f = df$biomarker) tabs <- lapply(df_subs, FUN = function(df_sub) { diff --git a/R/survival_coxph_pairwise.R b/R/survival_coxph_pairwise.R index bdf9092fe1..3c4b682eaa 100644 --- a/R/survival_coxph_pairwise.R +++ b/R/survival_coxph_pairwise.R @@ -14,6 +14,8 @@ #' * `ties` (`string`)\cr specifying the method for tie handling. Default is `"efron"`, #' can also be set to `"breslow"` or `"exact"`. See more in [survival::coxph()] #' * `conf_level` (`proportion`)\cr confidence level of the interval for HR. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("coxph_pairwise")` +#' to see available statistics for this function. #' #' @name survival_coxph_pairwise NULL diff --git a/R/survival_time.R b/R/survival_time.R index e7d96d1d47..7457e5eab2 100644 --- a/R/survival_time.R +++ b/R/survival_time.R @@ -12,6 +12,8 @@ #' * `conf_type` (`string`)\cr confidence interval type. Options are "plain" (default), "log", or "log-log", #' see more in [survival::survfit()]. Note option "none" is not supported. #' * `quantiles` (`numeric`)\cr vector of length two to specify the quantiles of survival time. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("surv_time")` +#' to see available statistics for this function. #' #' @name survival_time NULL diff --git a/R/survival_timepoint.R b/R/survival_timepoint.R index e32fda1113..4f42239d2f 100644 --- a/R/survival_timepoint.R +++ b/R/survival_timepoint.R @@ -13,6 +13,8 @@ #' * `conf_type` (`string`)\cr confidence interval type. Options are "plain" (default), "log", "log-log", #' see more in [survival::survfit()]. Note option "none" is no longer supported. #' * `time_point` (`number`)\cr survival time point of interest. +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("surv_timepoint")` +#' to see available statistics for this function. #' #' @name survival_timepoint NULL diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 00b72c35bf..02415faad6 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -336,6 +336,10 @@ tern_default_stats <- list( summarize_patients_events_in_cols = c("unique", "all"), surv_time = c("median", "median_ci", "quantiles", "range_censor", "range_event", "range"), surv_timepoint = c("pt_at_risk", "event_free_rate", "rate_se", "rate_ci", "rate_diff", "rate_diff_ci", "ztest_pval"), + tabulate_rsp_biomarkers = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), + tabulate_rsp_subgroups = c("n", "n_rsp", "prop", "n_tot", "or", "ci", "pval"), + tabulate_survival_biomarkers = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), + tabulate_survival_subgroups = c("n_tot_events", "n_events", "n_tot", "n", "median", "hr", "ci", "pval"), test_proportion_diff = c("pval") ) From 42d695b9ee18fc2cbee4002e25b727b67c59f3af Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 16:40:29 -0500 Subject: [PATCH 12/16] Update docs --- R/compare_variables.R | 3 +++ man/abnormal.Rd | 3 ++- man/abnormal_by_baseline.Rd | 3 ++- man/abnormal_by_marked.Rd | 3 ++- man/abnormal_by_worst_grade.Rd | 3 ++- man/abnormal_by_worst_grade_worsen.Rd | 3 ++- man/analyze_variables.Rd | 4 +++- man/compare_variables.Rd | 4 +++- man/count_cumulative.Rd | 3 ++- man/count_missed_doses.Rd | 3 ++- man/count_occurrences.Rd | 3 ++- man/count_occurrences_by_grade.Rd | 3 ++- man/count_patients_events_in_cols.Rd | 4 +++- man/count_patients_with_event.Rd | 3 ++- man/count_patients_with_flags.Rd | 3 ++- man/count_values_funs.Rd | 3 ++- man/d_survival_subgroups_colvars.Rd | 14 +------------- man/estimate_multinomial_rsp.Rd | 3 ++- man/estimate_proportions.Rd | 3 ++- man/h_response_biomarkers_subgroups.Rd | 11 +---------- man/h_survival_biomarkers_subgroups.Rd | 11 +---------- man/incidence_rate.Rd | 3 ++- man/odds_ratio.Rd | 3 ++- man/prop_diff.Rd | 3 ++- man/prop_diff_test.Rd | 3 ++- man/response_biomarkers_subgroups.Rd | 7 +++++-- man/response_subgroups.Rd | 11 +++++++++-- man/summarize_ancova.Rd | 3 ++- man/summarize_change.Rd | 3 ++- man/summarize_glm_count.Rd | 3 ++- man/summarize_num_patients.Rd | 3 ++- man/summarize_patients_exposure_in_cols.Rd | 3 ++- man/survival_biomarkers_subgroups.Rd | 11 +++++++---- man/survival_coxph_pairwise.Rd | 3 ++- man/survival_duration_subgroups.Rd | 11 +++++++---- man/survival_time.Rd | 3 ++- man/survival_timepoint.Rd | 3 ++- 37 files changed, 95 insertions(+), 74 deletions(-) diff --git a/R/compare_variables.R b/R/compare_variables.R index e82eda8459..20b8deb3d1 100644 --- a/R/compare_variables.R +++ b/R/compare_variables.R @@ -5,6 +5,9 @@ #' Comparison with a reference group for different `x` objects. #' #' @inheritParams argument_convention +#' @param .stats (`character`)\cr statistics to select for the table. Run `get_stats("analyze_vars_numeric")` to see +#' statistics available for numeric variables, and `get_stats("analyze_vars_counts")` for statistics available +#' for non-numeric variables. #' #' @note #' * For factor variables, `denom` for factor proportions can only be `n` since the purpose is to compare proportions diff --git a/man/abnormal.Rd b/man/abnormal.Rd index 0e50726669..623676559a 100644 --- a/man/abnormal.Rd +++ b/man/abnormal.Rd @@ -64,7 +64,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("abnormal")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/abnormal_by_baseline.Rd b/man/abnormal_by_baseline.Rd index 312721849c..4c9cfa0462 100644 --- a/man/abnormal_by_baseline.Rd +++ b/man/abnormal_by_baseline.Rd @@ -65,7 +65,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("abnormal_by_baseline")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/abnormal_by_marked.Rd b/man/abnormal_by_marked.Rd index 73a2ca8e54..4129bf5f54 100644 --- a/man/abnormal_by_marked.Rd +++ b/man/abnormal_by_marked.Rd @@ -59,7 +59,8 @@ underneath analyses, which is not allowed.} \item{...}{additional arguments for the lower level functions.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("abnormal_by_marked")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/abnormal_by_worst_grade.Rd b/man/abnormal_by_worst_grade.Rd index e9afd5d467..04d01e6769 100644 --- a/man/abnormal_by_worst_grade.Rd +++ b/man/abnormal_by_worst_grade.Rd @@ -54,7 +54,8 @@ underneath analyses, which is not allowed.} \item{...}{additional arguments for the lower level functions.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("abnormal_by_worst_grade")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/abnormal_by_worst_grade_worsen.Rd b/man/abnormal_by_worst_grade_worsen.Rd index 6e6254c234..96db79332a 100644 --- a/man/abnormal_by_worst_grade_worsen.Rd +++ b/man/abnormal_by_worst_grade_worsen.Rd @@ -58,7 +58,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("abnormal_by_worst_grade_worsen")} +to see all available statistics.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/analyze_variables.Rd b/man/analyze_variables.Rd index 29cf623b9c..45f30d9a67 100644 --- a/man/analyze_variables.Rd +++ b/man/analyze_variables.Rd @@ -138,7 +138,9 @@ to print out information about factor casting.} \item{compare}{(\code{logical})\cr Whether comparison statistics should be analyzed instead of summary statistics (\code{compare = TRUE} adds \code{pval} statistic comparing against reference group).} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("analyze_vars_numeric")} to see +statistics available for numeric variables, and \code{get_stats("analyze_vars_counts")} for statistics available +for non-numeric variables.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/compare_variables.Rd b/man/compare_variables.Rd index c937b6ceb8..750a8e1d27 100644 --- a/man/compare_variables.Rd +++ b/man/compare_variables.Rd @@ -109,7 +109,9 @@ to avoid warnings from \code{rtables}.} \item{section_div}{(\code{string})\cr string which should be repeated as a section divider after each group defined by this split instruction, or \code{NA_character_} (the default) for no section divider.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("analyze_vars_numeric")} to see +statistics available for numeric variables, and \code{get_stats("analyze_vars_counts")} for statistics available +for non-numeric variables.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_cumulative.Rd b/man/count_cumulative.Rd index f4a986a167..32b20fef79 100644 --- a/man/count_cumulative.Rd +++ b/man/count_cumulative.Rd @@ -70,7 +70,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_cumulative")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_missed_doses.Rd b/man/count_missed_doses.Rd index a4e02a3963..5757ac8fc5 100644 --- a/man/count_missed_doses.Rd +++ b/man/count_missed_doses.Rd @@ -55,7 +55,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_missed_doses")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_occurrences.Rd b/man/count_occurrences.Rd index f7c5f5d156..91328fc06b 100644 --- a/man/count_occurrences.Rd +++ b/man/count_occurrences.Rd @@ -87,7 +87,8 @@ by a statistics function.} (must be present as second argument in Content Row Functions). See \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}} for more information.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_occurrences")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_occurrences_by_grade.Rd b/man/count_occurrences_by_grade.Rd index 3222c09ead..3ab336c87c 100644 --- a/man/count_occurrences_by_grade.Rd +++ b/man/count_occurrences_by_grade.Rd @@ -95,7 +95,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_occurrences_by_grade")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_patients_events_in_cols.Rd b/man/count_patients_events_in_cols.Rd index 84011b90ce..78e1abcea5 100644 --- a/man/count_patients_events_in_cols.Rd +++ b/man/count_patients_events_in_cols.Rd @@ -52,7 +52,9 @@ be used as label.} \item{...}{additional arguments for the lower level functions.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run +\code{get_stats("summarize_patients_events_in_cols")} to see available statistics for this function, in addition to any +added using \code{filters_list}.} \item{.labels}{(named \code{character})\cr labels for the statistics (without indent).} diff --git a/man/count_patients_with_event.Rd b/man/count_patients_with_event.Rd index 173780583e..882abfe795 100644 --- a/man/count_patients_with_event.Rd +++ b/man/count_patients_with_event.Rd @@ -81,7 +81,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_patients_with_event")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_patients_with_flags.Rd b/man/count_patients_with_flags.Rd index 0464e49820..19981fcc13 100644 --- a/man/count_patients_with_flags.Rd +++ b/man/count_patients_with_flags.Rd @@ -88,7 +88,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_patients_with_flags")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/count_values_funs.Rd b/man/count_values_funs.Rd index 33d0d3b0e8..4a500b1723 100644 --- a/man/count_values_funs.Rd +++ b/man/count_values_funs.Rd @@ -83,7 +83,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("count_values")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/d_survival_subgroups_colvars.Rd b/man/d_survival_subgroups_colvars.Rd index c336aeb858..8eb00bafda 100644 --- a/man/d_survival_subgroups_colvars.Rd +++ b/man/d_survival_subgroups_colvars.Rd @@ -7,19 +7,7 @@ d_survival_subgroups_colvars(vars, conf_level, method, time_unit = NULL) } \arguments{ -\item{vars}{(\code{character})\cr the name of statistics to be reported among: -\itemize{ -\item \code{n_tot_events}: Total number of events per group. -\item \code{n_events}: Number of events per group. -\item \code{n_tot}: Total number of observations per group. -\item \code{n}: Number of observations per group. -\item \code{median}: Median survival time. -\item \code{hr}: Hazard ratio. -\item \code{ci}: Confidence interval of hazard ratio. -\item \code{pval}: p-value of the effect. -Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci} -are required. -}} +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} \item{conf_level}{(\code{proportion})\cr confidence level of the interval.} diff --git a/man/estimate_multinomial_rsp.Rd b/man/estimate_multinomial_rsp.Rd index b3cff3fb4d..9767dcba74 100644 --- a/man/estimate_multinomial_rsp.Rd +++ b/man/estimate_multinomial_rsp.Rd @@ -49,7 +49,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("estimate_multinomial_response")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/estimate_proportions.Rd b/man/estimate_proportions.Rd index 7fce15b0ec..e785b535f9 100644 --- a/man/estimate_proportions.Rd +++ b/man/estimate_proportions.Rd @@ -90,7 +90,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("estimate_proportion")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/h_response_biomarkers_subgroups.Rd b/man/h_response_biomarkers_subgroups.Rd index 04ae098657..a270b3df8e 100644 --- a/man/h_response_biomarkers_subgroups.Rd +++ b/man/h_response_biomarkers_subgroups.Rd @@ -28,16 +28,7 @@ returned by \code{\link[=extract_rsp_biomarkers]{extract_rsp_biomarkers()}} (it added by that high-level function relative to what is returned by \code{\link[=h_logistic_mult_cont_df]{h_logistic_mult_cont_df()}}, see the example).} -\item{vars}{(\code{character})\cr the names of statistics to be reported among: -\itemize{ -\item \code{n_tot}: Total number of patients per group. -\item \code{n_rsp}: Total number of responses per group. -\item \code{prop}: Total response proportion per group. -\item \code{or}: Odds ratio. -\item \code{ci}: Confidence interval of odds ratio. -\item \code{pval}: p-value of the effect. -Note, the statistics \code{n_tot}, \code{or} and \code{ci} are required. -}} +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} \item{.indent_mods}{(named \code{integer})\cr indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.} diff --git a/man/h_survival_biomarkers_subgroups.Rd b/man/h_survival_biomarkers_subgroups.Rd index f88dba3596..385afd7d6e 100644 --- a/man/h_survival_biomarkers_subgroups.Rd +++ b/man/h_survival_biomarkers_subgroups.Rd @@ -27,16 +27,7 @@ returned by \code{\link[=extract_survival_biomarkers]{extract_survival_biomarker added by that high-level function relative to what is returned by \code{\link[=h_coxreg_mult_cont_df]{h_coxreg_mult_cont_df()}}, see the example).} -\item{vars}{(\code{character})\cr the names of statistics to be reported among: -\itemize{ -\item \code{n_tot_events}: Total number of events per group. -\item \code{n_tot}: Total number of observations per group. -\item \code{median}: Median survival time. -\item \code{hr}: Hazard ratio. -\item \code{ci}: Confidence interval of hazard ratio. -\item \code{pval}: p-value of the effect. -Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci} are required. -}} +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} \item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} diff --git a/man/incidence_rate.Rd b/man/incidence_rate.Rd index 16db00037a..961e83c6db 100644 --- a/man/incidence_rate.Rd +++ b/man/incidence_rate.Rd @@ -75,7 +75,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("estimate_incidence_rate")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/odds_ratio.Rd b/man/odds_ratio.Rd index 6ab700ead7..d01e6082c7 100644 --- a/man/odds_ratio.Rd +++ b/man/odds_ratio.Rd @@ -79,7 +79,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("estimate_odds_ratio")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/prop_diff.Rd b/man/prop_diff.Rd index f6a60c42b4..880dffd42b 100644 --- a/man/prop_diff.Rd +++ b/man/prop_diff.Rd @@ -84,7 +84,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("estimate_proportion_diff")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/prop_diff_test.Rd b/man/prop_diff_test.Rd index 2babe8f7c4..af4a86a21b 100644 --- a/man/prop_diff_test.Rd +++ b/man/prop_diff_test.Rd @@ -74,7 +74,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("test_proportion_diff")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/response_biomarkers_subgroups.Rd b/man/response_biomarkers_subgroups.Rd index b43185f9a7..3f3027a559 100644 --- a/man/response_biomarkers_subgroups.Rd +++ b/man/response_biomarkers_subgroups.Rd @@ -7,7 +7,8 @@ \usage{ tabulate_rsp_biomarkers( df, - vars = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), + vars = lifecycle::deprecated(), + .stats = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), .indent_mods = 0L ) } @@ -15,7 +16,9 @@ tabulate_rsp_biomarkers( \item{df}{(\code{data.frame})\cr containing all analysis variables, as returned by \code{\link[=extract_rsp_biomarkers]{extract_rsp_biomarkers()}}.} -\item{vars}{(\code{character})\cr the names of statistics to be reported among: +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} + +\item{.stats}{(\code{character})\cr the names of statistics to be reported among: \itemize{ \item \code{n_tot}: Total number of patients per group. \item \code{n_rsp}: Total number of responses per group. diff --git a/man/response_subgroups.Rd b/man/response_subgroups.Rd index e03ee9dd70..77b748c3b0 100644 --- a/man/response_subgroups.Rd +++ b/man/response_subgroups.Rd @@ -12,7 +12,12 @@ a_response_subgroups( "x.xxxx | (<0.0001)") ) -tabulate_rsp_subgroups(lyt, df, vars = c("n_tot", "n", "prop", "or", "ci")) +tabulate_rsp_subgroups( + lyt, + df, + vars = lifecycle::deprecated(), + .stats = c("n_tot", "n", "prop", "or", "ci") +) } \arguments{ \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more @@ -23,7 +28,9 @@ information on the \code{"auto"} setting.} \item{df}{(\code{list})\cr of data frames containing all analysis variables. List should be created using \code{\link[=extract_rsp_subgroups]{extract_rsp_subgroups()}}.} -\item{vars}{(\code{character})\cr the names of statistics to be reported among: +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} + +\item{.stats}{(\code{character})\cr the names of statistics to be reported among: \itemize{ \item \code{n}: Total number of observations per group. \item \code{n_rsp}: Number of responders per group. diff --git a/man/summarize_ancova.Rd b/man/summarize_ancova.Rd index 4405cdac5d..8e40ef601a 100644 --- a/man/summarize_ancova.Rd +++ b/man/summarize_ancova.Rd @@ -88,7 +88,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("summarize_ancova")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/summarize_change.Rd b/man/summarize_change.Rd index fa056f3665..9bd064f942 100644 --- a/man/summarize_change.Rd +++ b/man/summarize_change.Rd @@ -48,7 +48,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \verb{get_stats("analyze_vars_numeric)} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/summarize_glm_count.Rd b/man/summarize_glm_count.Rd index 33c5f841dd..8704187af3 100644 --- a/man/summarize_glm_count.Rd +++ b/man/summarize_glm_count.Rd @@ -91,7 +91,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("summarize_glm_count")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/summarize_num_patients.Rd b/man/summarize_num_patients.Rd index 22ae0c0c0b..d6d0cdf86c 100644 --- a/man/summarize_num_patients.Rd +++ b/man/summarize_num_patients.Rd @@ -82,7 +82,8 @@ by a statistics function.} \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("summarize_num_patients")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/summarize_patients_exposure_in_cols.Rd b/man/summarize_patients_exposure_in_cols.Rd index 0d15ebfed3..5559c08f71 100644 --- a/man/summarize_patients_exposure_in_cols.Rd +++ b/man/summarize_patients_exposure_in_cols.Rd @@ -64,7 +64,8 @@ analyze_patients_exposure_in_cols( (must be present as second argument in Content Row Functions). See \code{\link[rtables:summarize_row_groups]{rtables::summarize_row_groups()}} for more information.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run +\code{get_stats("analyze_patients_exposure_in_cols")} to see available statistics for this function.} \item{.N_col}{(\code{integer})\cr column-wise N (column count) for the full column being analyzed that is typically passed by \code{rtables}.} diff --git a/man/survival_biomarkers_subgroups.Rd b/man/survival_biomarkers_subgroups.Rd index 6c35fd44ad..a6cdfc9478 100644 --- a/man/survival_biomarkers_subgroups.Rd +++ b/man/survival_biomarkers_subgroups.Rd @@ -7,8 +7,9 @@ \usage{ tabulate_survival_biomarkers( df, - vars = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), + vars = lifecycle::deprecated(), time_unit = NULL, + .stats = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), .indent_mods = 0L ) } @@ -16,7 +17,11 @@ tabulate_survival_biomarkers( \item{df}{(\code{data.frame})\cr containing all analysis variables, as returned by \code{\link[=extract_survival_biomarkers]{extract_survival_biomarkers()}}.} -\item{vars}{(\code{character})\cr the names of statistics to be reported among: +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} + +\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} + +\item{.stats}{(\code{character})\cr the names of statistics to be reported among: \itemize{ \item \code{n_tot_events}: Total number of events per group. \item \code{n_tot}: Total number of observations per group. @@ -27,8 +32,6 @@ tabulate_survival_biomarkers( Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci} are required. }} -\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} - \item{.indent_mods}{(named \code{integer})\cr indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.} } diff --git a/man/survival_coxph_pairwise.Rd b/man/survival_coxph_pairwise.Rd index 272d6e0f95..b3acb2b678 100644 --- a/man/survival_coxph_pairwise.Rd +++ b/man/survival_coxph_pairwise.Rd @@ -85,7 +85,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("coxph_pairwise")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/survival_duration_subgroups.Rd b/man/survival_duration_subgroups.Rd index 4dad3e1ece..2c7edc456e 100644 --- a/man/survival_duration_subgroups.Rd +++ b/man/survival_duration_subgroups.Rd @@ -15,8 +15,9 @@ a_survival_subgroups( tabulate_survival_subgroups( lyt, df, - vars = c("n_tot_events", "n_events", "median", "hr", "ci"), + vars = lifecycle::deprecated(), time_unit = NULL, + .stats = c("n_tot_events", "n_events", "median", "hr", "ci"), na_str = NA_character_ ) } @@ -29,7 +30,11 @@ information on the \code{"auto"} setting.} \item{df}{(\code{list})\cr of data frames containing all analysis variables. List should be created using \code{\link[=extract_survival_subgroups]{extract_survival_subgroups()}}.} -\item{vars}{(\code{character})\cr the name of statistics to be reported among: +\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} + +\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} + +\item{.stats}{(\code{character})\cr the name of statistics to be reported among: \itemize{ \item \code{n_tot_events}: Total number of events per group. \item \code{n_events}: Number of events per group. @@ -43,8 +48,6 @@ Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as bot are required. }} -\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} } \value{ diff --git a/man/survival_time.Rd b/man/survival_time.Rd index 8a72bca3b2..175af2dd53 100644 --- a/man/survival_time.Rd +++ b/man/survival_time.Rd @@ -60,7 +60,8 @@ underneath analyses, which is not allowed.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("surv_time")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} diff --git a/man/survival_timepoint.Rd b/man/survival_timepoint.Rd index 5160962dee..743fb427cc 100644 --- a/man/survival_timepoint.Rd +++ b/man/survival_timepoint.Rd @@ -112,7 +112,8 @@ avoid warnings from duplicate table names.} \item{method}{(\code{string})\cr either \code{surv} (survival estimations), \code{surv_diff} (difference in survival with the control) or \code{both}.} -\item{.stats}{(\code{character})\cr statistics to select for the table.} +\item{.stats}{(\code{character})\cr statistics to select for the table. Run \code{get_stats("surv_timepoint")} +to see available statistics for this function.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more information on the \code{"auto"} setting.} From 0857820dc4da4e73b2b0c9c18ed88975eda22560 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 16:51:08 -0500 Subject: [PATCH 13/16] Sync docs --- man/default_stats_formats_labels.Rd | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/man/default_stats_formats_labels.Rd b/man/default_stats_formats_labels.Rd index 899602794a..1c84fbea96 100644 --- a/man/default_stats_formats_labels.Rd +++ b/man/default_stats_formats_labels.Rd @@ -21,8 +21,8 @@ named for their corresponding statistical method group. } \itemize{ -\item \code{tern_default_formats} is a list of available formats, named after their relevant -statistic. +\item \code{tern_default_formats} is a named vector of available default formats, with each element +named for their corresponding statistic. } \itemize{ @@ -169,8 +169,7 @@ group (analyze function). \item \code{tern_default_formats}: Named vector of default formats for \code{tern}. -\item \code{tern_default_labels}: \code{character} vector that contains default labels -for \code{tern}. +\item \code{tern_default_labels}: Named \code{character} vector of default labels for \code{tern}. \item \code{summary_formats()}: Quick function to retrieve default formats for summary statistics: \code{\link[=analyze_vars]{analyze_vars()}} and \code{\link[=analyze_vars_in_cols]{analyze_vars_in_cols()}} principally. From 4d70e97d2eac38db551e68b3f17aaf17aad71232 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 17:09:45 -0500 Subject: [PATCH 14/16] Revert deprecation of arg name --- NEWS.md | 1 - R/response_biomarkers_subgroups.R | 10 ++-------- R/response_subgroups.R | 10 ++-------- R/survival_biomarkers_subgroups.R | 10 ++-------- R/survival_duration_subgroups.R | 10 ++-------- 5 files changed, 8 insertions(+), 33 deletions(-) diff --git a/NEWS.md b/NEWS.md index b2a35131e4..4e8b1fa3a1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,7 +19,6 @@ ### Miscellaneous * Specified minimal version of package dependencies. -* Began deprecation of `vars` argument in `tabulate_rsp_biomarkers`, `tabulate_rsp_subgroups`, `tabulate_survival_biomarkers`, and `tabulate_survival_subgroups` and replaced it with the `.stats` argument. # tern 0.9.2 diff --git a/R/response_biomarkers_subgroups.R b/R/response_biomarkers_subgroups.R index ca87a298b4..b22034b894 100644 --- a/R/response_biomarkers_subgroups.R +++ b/R/response_biomarkers_subgroups.R @@ -8,7 +8,7 @@ #' @inheritParams argument_convention #' @param df (`data.frame`)\cr containing all analysis variables, as returned by #' [extract_rsp_biomarkers()]. -#' @param .stats (`character`)\cr the names of statistics to be reported among: +#' @param vars (`character`)\cr the names of statistics to be reported among: #' * `n_tot`: Total number of patients per group. #' * `n_rsp`: Total number of responses per group. #' * `prop`: Total response proportion per group. @@ -67,14 +67,8 @@ #' @export #' @name response_biomarkers_subgroups tabulate_rsp_biomarkers <- function(df, - vars = lifecycle::deprecated(), - .stats = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), + vars = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), .indent_mods = 0L) { - if (lifecycle::is_present(vars)) { - lifecycle::deprecate_warn("0.9.3", "tabulate_rsp_biomarkers(vars)", "tabulate_rsp_biomarkers(.stats)") - .stats <- vars - } - checkmate::assert_data_frame(df) checkmate::assert_character(df$biomarker) checkmate::assert_character(df$biomarker_label) diff --git a/R/response_subgroups.R b/R/response_subgroups.R index 7ea3c467bc..e194b1542d 100644 --- a/R/response_subgroups.R +++ b/R/response_subgroups.R @@ -178,7 +178,7 @@ a_response_subgroups <- function(.formats = list( #' #' @param df (`list`)\cr of data frames containing all analysis variables. List should be #' created using [extract_rsp_subgroups()]. -#' @param .stats (`character`)\cr the names of statistics to be reported among: +#' @param vars (`character`)\cr the names of statistics to be reported among: #' * `n`: Total number of observations per group. #' * `n_rsp`: Number of responders per group. #' * `prop`: Proportion of responders. @@ -205,13 +205,7 @@ a_response_subgroups <- function(.formats = list( #' @export tabulate_rsp_subgroups <- function(lyt, df, - vars = lifecycle::deprecated(), - .stats = c("n_tot", "n", "prop", "or", "ci")) { - if (lifecycle::is_present(vars)) { - lifecycle::deprecate_warn("0.9.3", "tabulate_rsp_subgroups(vars)", "tabulate_rsp_subgroups(.stats)") - .stats <- vars - } - + vars = c("n_tot", "n", "prop", "or", "ci")) { conf_level <- df$or$conf_level[1] method <- if ("pval_label" %in% names(df$or)) { df$or$pval_label[1] diff --git a/R/survival_biomarkers_subgroups.R b/R/survival_biomarkers_subgroups.R index c14184b5ff..3c59f0204f 100644 --- a/R/survival_biomarkers_subgroups.R +++ b/R/survival_biomarkers_subgroups.R @@ -172,7 +172,7 @@ extract_survival_biomarkers <- function(variables, #' #' @param df (`data.frame`)\cr containing all analysis variables, as returned by #' [extract_survival_biomarkers()]. -#' @param .stats (`character`)\cr the names of statistics to be reported among: +#' @param vars (`character`)\cr the names of statistics to be reported among: #' * `n_tot_events`: Total number of events per group. #' * `n_tot`: Total number of observations per group. #' * `median`: Median survival time. @@ -207,15 +207,9 @@ extract_survival_biomarkers <- function(variables, #' #' @export tabulate_survival_biomarkers <- function(df, - vars = lifecycle::deprecated(), + vars = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), time_unit = NULL, - .stats = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), .indent_mods = 0L) { - if (lifecycle::is_present(vars)) { - lifecycle::deprecate_warn("0.9.3", "tabulate_survival_biomarkers(vars)", "tabulate_survival_biomarkers(.stats)") - .stats <- vars - } - checkmate::assert_data_frame(df) checkmate::assert_character(df$biomarker) checkmate::assert_character(df$biomarker_label) diff --git a/R/survival_duration_subgroups.R b/R/survival_duration_subgroups.R index 2a4f2a365d..4f50bd466c 100644 --- a/R/survival_duration_subgroups.R +++ b/R/survival_duration_subgroups.R @@ -212,7 +212,7 @@ a_survival_subgroups <- function(.formats = list( # nolint start #' #' @param df (`list`)\cr of data frames containing all analysis variables. List should be #' created using [extract_survival_subgroups()]. -#' @param .stats (`character`)\cr the name of statistics to be reported among: +#' @param vars (`character`)\cr the name of statistics to be reported among: #' * `n_tot_events`: Total number of events per group. #' * `n_events`: Number of events per group. #' * `n_tot`: Total number of observations per group. @@ -242,15 +242,9 @@ a_survival_subgroups <- function(.formats = list( # nolint start #' @export tabulate_survival_subgroups <- function(lyt, df, - vars = lifecycle::deprecated(), + vars = c("n_tot_events", "n_events", "median", "hr", "ci"), time_unit = NULL, - .stats = c("n_tot_events", "n_events", "median", "hr", "ci"), na_str = NA_character_) { - if (lifecycle::is_present(vars)) { - lifecycle::deprecate_warn("0.9.3", "tabulate_survival_subgroups(vars)", "tabulate_survival_subgroups(.stats)") - .stats <- vars - } - conf_level <- df$hr$conf_level[1] method <- df$hr$pval_label[1] From 9b8695b1f3de353fcf79e2dfaf6f3d920a902970 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:12:19 +0000 Subject: [PATCH 15/16] [skip actions] Roxygen Man Pages Auto Update --- man/d_survival_subgroups_colvars.Rd | 14 +++++++++++++- man/h_response_biomarkers_subgroups.Rd | 11 ++++++++++- man/h_survival_biomarkers_subgroups.Rd | 11 ++++++++++- man/response_biomarkers_subgroups.Rd | 7 ++----- man/response_subgroups.Rd | 11 ++--------- man/survival_biomarkers_subgroups.Rd | 11 ++++------- man/survival_duration_subgroups.Rd | 11 ++++------- 7 files changed, 45 insertions(+), 31 deletions(-) diff --git a/man/d_survival_subgroups_colvars.Rd b/man/d_survival_subgroups_colvars.Rd index 8eb00bafda..c336aeb858 100644 --- a/man/d_survival_subgroups_colvars.Rd +++ b/man/d_survival_subgroups_colvars.Rd @@ -7,7 +7,19 @@ d_survival_subgroups_colvars(vars, conf_level, method, time_unit = NULL) } \arguments{ -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} +\item{vars}{(\code{character})\cr the name of statistics to be reported among: +\itemize{ +\item \code{n_tot_events}: Total number of events per group. +\item \code{n_events}: Number of events per group. +\item \code{n_tot}: Total number of observations per group. +\item \code{n}: Number of observations per group. +\item \code{median}: Median survival time. +\item \code{hr}: Hazard ratio. +\item \code{ci}: Confidence interval of hazard ratio. +\item \code{pval}: p-value of the effect. +Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci} +are required. +}} \item{conf_level}{(\code{proportion})\cr confidence level of the interval.} diff --git a/man/h_response_biomarkers_subgroups.Rd b/man/h_response_biomarkers_subgroups.Rd index a270b3df8e..04ae098657 100644 --- a/man/h_response_biomarkers_subgroups.Rd +++ b/man/h_response_biomarkers_subgroups.Rd @@ -28,7 +28,16 @@ returned by \code{\link[=extract_rsp_biomarkers]{extract_rsp_biomarkers()}} (it added by that high-level function relative to what is returned by \code{\link[=h_logistic_mult_cont_df]{h_logistic_mult_cont_df()}}, see the example).} -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} +\item{vars}{(\code{character})\cr the names of statistics to be reported among: +\itemize{ +\item \code{n_tot}: Total number of patients per group. +\item \code{n_rsp}: Total number of responses per group. +\item \code{prop}: Total response proportion per group. +\item \code{or}: Odds ratio. +\item \code{ci}: Confidence interval of odds ratio. +\item \code{pval}: p-value of the effect. +Note, the statistics \code{n_tot}, \code{or} and \code{ci} are required. +}} \item{.indent_mods}{(named \code{integer})\cr indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.} diff --git a/man/h_survival_biomarkers_subgroups.Rd b/man/h_survival_biomarkers_subgroups.Rd index 385afd7d6e..f88dba3596 100644 --- a/man/h_survival_biomarkers_subgroups.Rd +++ b/man/h_survival_biomarkers_subgroups.Rd @@ -27,7 +27,16 @@ returned by \code{\link[=extract_survival_biomarkers]{extract_survival_biomarker added by that high-level function relative to what is returned by \code{\link[=h_coxreg_mult_cont_df]{h_coxreg_mult_cont_df()}}, see the example).} -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} +\item{vars}{(\code{character})\cr the names of statistics to be reported among: +\itemize{ +\item \code{n_tot_events}: Total number of events per group. +\item \code{n_tot}: Total number of observations per group. +\item \code{median}: Median survival time. +\item \code{hr}: Hazard ratio. +\item \code{ci}: Confidence interval of hazard ratio. +\item \code{pval}: p-value of the effect. +Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci} are required. +}} \item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} diff --git a/man/response_biomarkers_subgroups.Rd b/man/response_biomarkers_subgroups.Rd index 3f3027a559..b43185f9a7 100644 --- a/man/response_biomarkers_subgroups.Rd +++ b/man/response_biomarkers_subgroups.Rd @@ -7,8 +7,7 @@ \usage{ tabulate_rsp_biomarkers( df, - vars = lifecycle::deprecated(), - .stats = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), + vars = c("n_tot", "n_rsp", "prop", "or", "ci", "pval"), .indent_mods = 0L ) } @@ -16,9 +15,7 @@ tabulate_rsp_biomarkers( \item{df}{(\code{data.frame})\cr containing all analysis variables, as returned by \code{\link[=extract_rsp_biomarkers]{extract_rsp_biomarkers()}}.} -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} - -\item{.stats}{(\code{character})\cr the names of statistics to be reported among: +\item{vars}{(\code{character})\cr the names of statistics to be reported among: \itemize{ \item \code{n_tot}: Total number of patients per group. \item \code{n_rsp}: Total number of responses per group. diff --git a/man/response_subgroups.Rd b/man/response_subgroups.Rd index 77b748c3b0..e03ee9dd70 100644 --- a/man/response_subgroups.Rd +++ b/man/response_subgroups.Rd @@ -12,12 +12,7 @@ a_response_subgroups( "x.xxxx | (<0.0001)") ) -tabulate_rsp_subgroups( - lyt, - df, - vars = lifecycle::deprecated(), - .stats = c("n_tot", "n", "prop", "or", "ci") -) +tabulate_rsp_subgroups(lyt, df, vars = c("n_tot", "n", "prop", "or", "ci")) } \arguments{ \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics. See Details in \code{analyze_vars} for more @@ -28,9 +23,7 @@ information on the \code{"auto"} setting.} \item{df}{(\code{list})\cr of data frames containing all analysis variables. List should be created using \code{\link[=extract_rsp_subgroups]{extract_rsp_subgroups()}}.} -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} - -\item{.stats}{(\code{character})\cr the names of statistics to be reported among: +\item{vars}{(\code{character})\cr the names of statistics to be reported among: \itemize{ \item \code{n}: Total number of observations per group. \item \code{n_rsp}: Number of responders per group. diff --git a/man/survival_biomarkers_subgroups.Rd b/man/survival_biomarkers_subgroups.Rd index a6cdfc9478..6c35fd44ad 100644 --- a/man/survival_biomarkers_subgroups.Rd +++ b/man/survival_biomarkers_subgroups.Rd @@ -7,9 +7,8 @@ \usage{ tabulate_survival_biomarkers( df, - vars = lifecycle::deprecated(), + vars = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), time_unit = NULL, - .stats = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"), .indent_mods = 0L ) } @@ -17,11 +16,7 @@ tabulate_survival_biomarkers( \item{df}{(\code{data.frame})\cr containing all analysis variables, as returned by \code{\link[=extract_survival_biomarkers]{extract_survival_biomarkers()}}.} -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} - -\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} - -\item{.stats}{(\code{character})\cr the names of statistics to be reported among: +\item{vars}{(\code{character})\cr the names of statistics to be reported among: \itemize{ \item \code{n_tot_events}: Total number of events per group. \item \code{n_tot}: Total number of observations per group. @@ -32,6 +27,8 @@ tabulate_survival_biomarkers( Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as both \code{hr} and \code{ci} are required. }} +\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} + \item{.indent_mods}{(named \code{integer})\cr indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.} } diff --git a/man/survival_duration_subgroups.Rd b/man/survival_duration_subgroups.Rd index 2c7edc456e..4dad3e1ece 100644 --- a/man/survival_duration_subgroups.Rd +++ b/man/survival_duration_subgroups.Rd @@ -15,9 +15,8 @@ a_survival_subgroups( tabulate_survival_subgroups( lyt, df, - vars = lifecycle::deprecated(), + vars = c("n_tot_events", "n_events", "median", "hr", "ci"), time_unit = NULL, - .stats = c("n_tot_events", "n_events", "median", "hr", "ci"), na_str = NA_character_ ) } @@ -30,11 +29,7 @@ information on the \code{"auto"} setting.} \item{df}{(\code{list})\cr of data frames containing all analysis variables. List should be created using \code{\link[=extract_survival_subgroups]{extract_survival_subgroups()}}.} -\item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} - -\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} - -\item{.stats}{(\code{character})\cr the name of statistics to be reported among: +\item{vars}{(\code{character})\cr the name of statistics to be reported among: \itemize{ \item \code{n_tot_events}: Total number of events per group. \item \code{n_events}: Number of events per group. @@ -48,6 +43,8 @@ Note, one of the statistics \code{n_tot} and \code{n_tot_events}, as well as bot are required. }} +\item{time_unit}{(\code{string})\cr label with unit of median survival time. Default \code{NULL} skips displaying unit.} + \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} } \value{ From 6db1432399666c173b1adfd4cca1da3ae23a6aaf Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 6 Nov 2023 17:21:27 -0500 Subject: [PATCH 16/16] Empty commit