From 8a01cf09fdaa8c58225dd387283793e0f60b7112 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 15:31:05 -0400 Subject: [PATCH 01/10] na_level parameter (0.9.1) --- NEWS.md | 1 + R/abnormal_by_baseline.R | 6 ------ R/analyze_variables.R | 13 ------------ R/analyze_vars_in_cols.R | 5 ----- R/argument_convention.R | 1 - R/compare_variables.R | 6 ------ R/h_map_for_count_abnormal.R | 6 ------ R/h_stack_by_baskets.R | 6 ------ R/summarize_colvars.R | 6 ------ R/summarize_coxreg.R | 12 ----------- man/abnormal_by_baseline.Rd | 4 ---- man/analyze_variables.Rd | 4 ---- man/analyze_vars_in_cols.Rd | 3 --- man/argument_convention.Rd | 2 -- man/compare_variables.Rd | 3 --- man/cox_regression.Rd | 4 ---- man/h_map_for_count_abnormal.Rd | 3 --- man/h_stack_by_baskets.Rd | 3 --- man/summarize_colvars.Rd | 3 --- man/to_string_matrix.Rd | 28 +++++++++++--------------- tests/testthat/test-summarize_coxreg.R | 11 ---------- 21 files changed, 13 insertions(+), 117 deletions(-) diff --git a/NEWS.md b/NEWS.md index 021a1f0a8d..dd35428909 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,7 @@ * Began deprecation of the named element `strat`, to be renamed to `strata`, within the `variables` argument to `h_rsp_to_logistic_variables`, `h_logistic_mult_cont_df`, `h_odds_ratio_subgroups_df`, `h_coxreg_mult_cont_df`, `h_coxph_subgroups_df`, `h_tbl_coxph_pairwise`, `extract_rsp_biomarkers`, `extract_rsp_subgroups`, `extract_survival_biomarkers`, and `extract_survival_subgroups`. * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. +* Remove all deprecated instances of the `na_level` parameter. # tern 0.9.3 diff --git a/R/abnormal_by_baseline.R b/R/abnormal_by_baseline.R index 62c62c52c2..e531e07fee 100644 --- a/R/abnormal_by_baseline.R +++ b/R/abnormal_by_baseline.R @@ -71,14 +71,8 @@ d_count_abnormal_by_baseline <- function(abnormal) { s_count_abnormal_by_baseline <- function(df, .var, abnormal, - na_level = lifecycle::deprecated(), na_str = "", variables = list(id = "USUBJID", baseline = "BNRIND")) { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "s_count_abnormal_by_baseline(na_level)", "s_count_abnormal_by_baseline(na_str)") - na_str <- na_level - } - checkmate::assert_string(.var) checkmate::assert_string(abnormal) checkmate::assert_string(na_str) diff --git a/R/analyze_variables.R b/R/analyze_variables.R index a07faf22b1..9fe2c1b789 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -480,15 +480,8 @@ a_summary <- function(x, .labels = NULL, .indent_mods = NULL, na.rm = TRUE, # nolint - na_level = lifecycle::deprecated(), na_str = default_na_str(), ...) { - extra_args <- list(...) - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "a_summary(na_level)", "a_summary(na_str)") - na_str <- na_level - } - if (is.numeric(x)) { type <- "numeric" if (!is.null(.stats) && any(grepl("^pval", .stats))) { @@ -669,7 +662,6 @@ create_afun_summary <- function(.stats, .formats, .labels, .indent_mods) { analyze_vars <- function(lyt, vars, var_labels = vars, - na_level = lifecycle::deprecated(), na_str = default_na_str(), nested = TRUE, ..., @@ -681,11 +673,6 @@ analyze_vars <- function(lyt, .formats = NULL, .labels = NULL, .indent_mods = NULL) { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "analyze_vars(na_level)", "analyze_vars(na_str)") - na_str <- na_level - } - extra_args <- list(.stats = .stats, na.rm = na.rm, na_str = na_str, ...) if (!is.null(.formats)) extra_args[[".formats"]] <- .formats if (!is.null(.labels)) extra_args[[".labels"]] <- .labels diff --git a/R/analyze_vars_in_cols.R b/R/analyze_vars_in_cols.R index 8fbc95b716..0467a2795a 100644 --- a/R/analyze_vars_in_cols.R +++ b/R/analyze_vars_in_cols.R @@ -158,16 +158,11 @@ analyze_vars_in_cols <- function(lyt, avalcat_var = "AVALCAT1", cache = FALSE, .indent_mods = NULL, - na_level = lifecycle::deprecated(), na_str = default_na_str(), nested = TRUE, .formats = NULL, .aligns = NULL) { extra_args <- list(...) - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "analyze_vars_in_cols(na_level)", "analyze_vars_in_cols(na_str)") - na_str <- na_level - } checkmate::assert_string(na_str, na.ok = TRUE, null.ok = TRUE) checkmate::assert_character(row_labels, null.ok = TRUE) diff --git a/R/argument_convention.R b/R/argument_convention.R index e72491b7d1..70efc82e19 100644 --- a/R/argument_convention.R +++ b/R/argument_convention.R @@ -46,7 +46,6 @@ #' @param method (`string`)\cr specifies the test used to calculate the p-value for the difference between #' two proportions. For options, see [s_test_proportion_diff()]. Default is `NULL` so no test is performed. #' @param na.rm (`flag`)\cr whether `NA` values should be removed from `x` prior to analysis. -#' @param na_level `r lifecycle::badge("deprecated")` Please use the `na_str` argument instead. #' @param na_str (`string`)\cr string used to replace all `NA` or empty values in the output. #' @param nested (`flag`)\cr whether this layout instruction should be applied within the existing layout structure _if #' possible_ (`TRUE`, the default) or as a new top-level element (`FALSE`). Ignored if it would nest a split. diff --git a/R/compare_variables.R b/R/compare_variables.R index 63ac6cf5d7..3902bbb174 100644 --- a/R/compare_variables.R +++ b/R/compare_variables.R @@ -373,7 +373,6 @@ create_afun_compare <- function(.stats = NULL, compare_vars <- function(lyt, vars, var_labels = vars, - na_level = lifecycle::deprecated(), na_str = default_na_str(), nested = TRUE, ..., @@ -385,11 +384,6 @@ compare_vars <- function(lyt, .formats = NULL, .labels = NULL, .indent_mods = NULL) { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "compare_vars(na_level)", "compare_vars(na_str)") - na_str <- na_level - } - extra_args <- list(.stats = .stats, na.rm = na.rm, na_str = na_str, compare = TRUE, ...) if (!is.null(.formats)) extra_args[[".formats"]] <- .formats if (!is.null(.labels)) extra_args[[".labels"]] <- .labels diff --git a/R/h_map_for_count_abnormal.R b/R/h_map_for_count_abnormal.R index e6d73eb98a..b4444725ab 100644 --- a/R/h_map_for_count_abnormal.R +++ b/R/h_map_for_count_abnormal.R @@ -71,13 +71,7 @@ h_map_for_count_abnormal <- function(df, ), abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")), method = c("default", "range"), - na_level = lifecycle::deprecated(), na_str = "") { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "h_map_for_count_abnormal(na_level)", "h_map_for_count_abnormal(na_str)") - na_str <- na_level - } - method <- match.arg(method) checkmate::assert_subset(c("anl", "split_rows"), names(variables)) checkmate::assert_false(anyNA(df[variables$split_rows])) diff --git a/R/h_stack_by_baskets.R b/R/h_stack_by_baskets.R index 9ee0da06eb..775ca01ece 100644 --- a/R/h_stack_by_baskets.R +++ b/R/h_stack_by_baskets.R @@ -62,13 +62,7 @@ h_stack_by_baskets <- function(df, smq_varlabel = "Standardized MedDRA Query", keys = c("STUDYID", "USUBJID", "ASTDTM", "AEDECOD", "AESEQ"), aag_summary = NULL, - na_level = lifecycle::deprecated(), na_str = "") { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "h_stack_by_baskets(na_level)", "h_stack_by_baskets(na_str)") - na_str <- na_level - } - smq_nam <- baskets[startsWith(baskets, "SMQ")] # SC corresponding to NAM smq_sc <- gsub(pattern = "NAM", replacement = "SC", x = smq_nam, fixed = TRUE) diff --git a/R/summarize_colvars.R b/R/summarize_colvars.R index aa9fae0ebb..6346c6f44c 100644 --- a/R/summarize_colvars.R +++ b/R/summarize_colvars.R @@ -62,17 +62,11 @@ #' @export summarize_colvars <- function(lyt, ..., - na_level = lifecycle::deprecated(), na_str = default_na_str(), .stats = c("n", "mean_sd", "median", "range", "count_fraction"), .formats = NULL, .labels = NULL, .indent_mods = NULL) { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "summarize_colvars(na_level)", "summarize_colvars(na_str)") - na_str <- na_level - } - extra_args <- list(.stats = .stats, na_str = na_str, ...) if (!is.null(.formats)) extra_args[[".formats"]] <- .formats if (!is.null(.labels)) extra_args[[".labels"]] <- .labels diff --git a/R/summarize_coxreg.R b/R/summarize_coxreg.R index 3366f7f4a0..078527822a 100644 --- a/R/summarize_coxreg.R +++ b/R/summarize_coxreg.R @@ -194,14 +194,8 @@ a_coxreg <- function(df, .stats, .formats, .indent_mods = NULL, - na_level = lifecycle::deprecated(), na_str = "", cache_env = NULL) { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "a_coxreg(na_level)", "a_coxreg(na_str)") - na_str <- na_level - } - cov_no_arm <- !multivar && !"arm" %in% names(variables) && control$interaction # special case: univar no arm cov <- tail(.spl_context$value, 1) # current variable/covariate var_lbl <- formatters::var_labels(df)[cov] # check for df labels @@ -339,14 +333,8 @@ summarize_coxreg <- function(lyt, ), varlabels = NULL, .indent_mods = NULL, - na_level = lifecycle::deprecated(), na_str = "", .section_div = NA_character_) { - if (lifecycle::is_present(na_level)) { - lifecycle::deprecate_warn("0.9.1", "summarize_coxreg(na_level)", "summarize_coxreg(na_str)") - na_str <- na_level - } - if (multivar && control$interaction) { warning(paste( "Interactions are not available for multivariate cox regression using summarize_coxreg.", diff --git a/man/abnormal_by_baseline.Rd b/man/abnormal_by_baseline.Rd index 9e420d6c6c..42c9842dd3 100644 --- a/man/abnormal_by_baseline.Rd +++ b/man/abnormal_by_baseline.Rd @@ -26,7 +26,6 @@ s_count_abnormal_by_baseline( df, .var, abnormal, - na_level = lifecycle::deprecated(), na_str = "", variables = list(id = "USUBJID", baseline = "BNRIND") ) @@ -35,7 +34,6 @@ a_count_abnormal_by_baseline( df, .var, abnormal, - na_level = lifecycle::deprecated(), na_str = "", variables = list(id = "USUBJID", baseline = "BNRIND") ) @@ -74,8 +72,6 @@ unmodified default behavior. Can be negative.} \item{.var, var}{(\code{string})\cr single variable name that is passed by \code{rtables} when requested by a statistics function.} - -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} } \value{ \itemize{ diff --git a/man/analyze_variables.Rd b/man/analyze_variables.Rd index 806da4dba1..f361812933 100644 --- a/man/analyze_variables.Rd +++ b/man/analyze_variables.Rd @@ -16,7 +16,6 @@ analyze_vars( lyt, vars, var_labels = vars, - na_level = lifecycle::deprecated(), na_str = default_na_str(), nested = TRUE, ..., @@ -86,7 +85,6 @@ a_summary( .labels = NULL, .indent_mods = NULL, na.rm = TRUE, - na_level = lifecycle::deprecated(), na_str = default_na_str(), ... ) @@ -100,8 +98,6 @@ summarize_vars(...) \item{var_labels}{(\code{character})\cr character for label.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} \item{nested}{(\code{flag})\cr whether this layout instruction should be applied within the existing layout structure \emph{if diff --git a/man/analyze_vars_in_cols.Rd b/man/analyze_vars_in_cols.Rd index 3c7ef455a1..075d522f2a 100644 --- a/man/analyze_vars_in_cols.Rd +++ b/man/analyze_vars_in_cols.Rd @@ -18,7 +18,6 @@ analyze_vars_in_cols( avalcat_var = "AVALCAT1", cache = FALSE, .indent_mods = NULL, - na_level = lifecycle::deprecated(), na_str = default_na_str(), nested = TRUE, .formats = NULL, @@ -66,8 +65,6 @@ used for multiple tables with different data. Defaults to \code{FALSE}.} \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.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} \item{nested}{(\code{flag})\cr whether this layout instruction should be applied within the existing layout structure \emph{if diff --git a/man/argument_convention.Rd b/man/argument_convention.Rd index 6ddd8a8226..44ae90c2f7 100644 --- a/man/argument_convention.Rd +++ b/man/argument_convention.Rd @@ -76,8 +76,6 @@ two proportions. For options, see \code{\link[=s_test_proportion_diff]{s_test_pr \item{na.rm}{(\code{flag})\cr whether \code{NA} values should be removed from \code{x} prior to analysis.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} \item{nested}{(\code{flag})\cr whether this layout instruction should be applied within the existing layout structure \emph{if diff --git a/man/compare_variables.Rd b/man/compare_variables.Rd index 9ed22a114f..2b8dc276f5 100644 --- a/man/compare_variables.Rd +++ b/man/compare_variables.Rd @@ -15,7 +15,6 @@ compare_vars( lyt, vars, var_labels = vars, - na_level = lifecycle::deprecated(), na_str = default_na_str(), nested = TRUE, ..., @@ -66,8 +65,6 @@ a_compare( \item{var_labels}{(\code{character})\cr character for label.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} \item{nested}{(\code{flag})\cr whether this layout instruction should be applied within the existing layout structure \emph{if diff --git a/man/cox_regression.Rd b/man/cox_regression.Rd index 5257372482..8d3b56c562 100644 --- a/man/cox_regression.Rd +++ b/man/cox_regression.Rd @@ -19,7 +19,6 @@ summarize_coxreg( "x.xxxx | (<0.0001)", pval_inter = "x.xxxx | (<0.0001)"), varlabels = NULL, .indent_mods = NULL, - na_level = lifecycle::deprecated(), na_str = "", .section_div = NA_character_ ) @@ -39,7 +38,6 @@ a_coxreg( .stats, .formats, .indent_mods = NULL, - na_level = lifecycle::deprecated(), na_str = "", cache_env = NULL ) @@ -80,8 +78,6 @@ effect estimates will be tabulated later.} \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.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr custom string to replace all \code{NA} values with. Defaults to \code{""}.} \item{.section_div}{(\code{character})\cr string which should be repeated as a section divider between sections. diff --git a/man/h_map_for_count_abnormal.Rd b/man/h_map_for_count_abnormal.Rd index 332b28c225..4304417677 100644 --- a/man/h_map_for_count_abnormal.Rd +++ b/man/h_map_for_count_abnormal.Rd @@ -10,7 +10,6 @@ h_map_for_count_abnormal( range_high = "ANRHI"), abnormal = list(low = c("LOW", "LOW LOW"), high = c("HIGH", "HIGH HIGH")), method = c("default", "range"), - na_level = lifecycle::deprecated(), na_str = "" ) } @@ -25,8 +24,6 @@ abnormality of the input dataset, it can be something like \code{list(Low = "LOW \item{method}{(\code{string})\cr indicates how the returned map will be constructed. Can be \code{"default"} or \code{"range"}.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} } \value{ diff --git a/man/h_stack_by_baskets.Rd b/man/h_stack_by_baskets.Rd index c4f03fc513..5058dc29e4 100644 --- a/man/h_stack_by_baskets.Rd +++ b/man/h_stack_by_baskets.Rd @@ -10,7 +10,6 @@ h_stack_by_baskets( smq_varlabel = "Standardized MedDRA Query", keys = c("STUDYID", "USUBJID", "ASTDTM", "AEDECOD", "AESEQ"), aag_summary = NULL, - na_level = lifecycle::deprecated(), na_str = "" ) } @@ -27,8 +26,6 @@ h_stack_by_baskets( variable. This is useful when there are some levels of interest that are not observed in the \code{df} dataset. The two columns of this dataset should be named \code{basket} and \code{basket_name}.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \item{na_str}{(\code{string})\cr string used to replace all \code{NA} or empty values in the output.} } \value{ diff --git a/man/summarize_colvars.Rd b/man/summarize_colvars.Rd index 7dc25936c6..b9efdd2f2c 100644 --- a/man/summarize_colvars.Rd +++ b/man/summarize_colvars.Rd @@ -7,7 +7,6 @@ summarize_colvars( lyt, ..., - na_level = lifecycle::deprecated(), na_str = default_na_str(), .stats = c("n", "mean_sd", "median", "range", "count_fraction"), .formats = NULL, @@ -20,8 +19,6 @@ summarize_colvars( \item{...}{arguments passed to \code{s_summary()}.} -\item{na_level}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{na_str} argument instead.} - \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.} diff --git a/man/to_string_matrix.Rd b/man/to_string_matrix.Rd index 0816f1fd02..ee33f4b57a 100644 --- a/man/to_string_matrix.Rd +++ b/man/to_string_matrix.Rd @@ -16,22 +16,18 @@ to_string_matrix( \arguments{ \item{x}{\code{rtables} table.} -\item{widths}{numeric (or \code{NULL}). (proposed) widths for the columns -of \code{x}. The expected length of this numeric vector can be -retrieved with \code{ncol() + 1} as the column of row names must -also be considered.} - -\item{max_width}{integer(1), character(1) or \code{NULL}. Width that title -and footer (including footnotes) materials should be -word-wrapped to. If \code{NULL}, it is set to the current print width -of the session (\code{getOption("width")}). If set to \code{"auto"}, -the width of the table (plus any table inset) is used. Ignored -completely if \code{tf_wrap} is \code{FALSE}.} - -\item{hsep}{character(1). Characters to repeat to create -header/body separator line. If \code{NULL}, the object value will be -used. If \code{" "}, an empty separator will be printed. Check \code{\link[formatters:default_hsep]{default_hsep()}} -for more information.} +\item{widths}{(\code{numeric} or \code{NULL})\cr Proposed widths for the columns of \code{x}. The expected +length of this numeric vector can be retrieved with \code{ncol(x) + 1} as the column of row names +must also be considered.} + +\item{max_width}{(\code{integer(1)}, \code{character(1)} or \code{NULL})\cr width that title and footer (including +footnotes) materials should be word-wrapped to. If \code{NULL}, it is set to the current print width of the +session (\code{getOption("width")}). If set to \code{"auto"}, the width of the table (plus any table inset) is +used. Parameter is ignored if \code{tf_wrap = FALSE}.} + +\item{hsep}{(\code{character(1)})\cr character to repeat to create header/body separator line. If +\code{NULL}, the object value will be used. If \code{" "}, an empty separator will be printed. See +\code{\link[formatters:default_hsep]{default_hsep()}} for more information.} \item{with_spaces}{(\code{logical})\cr should the tested table keep the indentation and other relevant spaces?} diff --git a/tests/testthat/test-summarize_coxreg.R b/tests/testthat/test-summarize_coxreg.R index d7c827425e..f036faff66 100644 --- a/tests/testthat/test-summarize_coxreg.R +++ b/tests/testthat/test-summarize_coxreg.R @@ -171,17 +171,6 @@ testthat::test_that("summarize_coxreg `na_str` argument works", { res <- testthat::expect_silent(result) testthat::expect_snapshot(res) - - # deprecation message for `na_level` is correct - suppressWarnings(testthat::expect_warning( - result <- basic_table() %>% - summarize_coxreg( - variables = variables, - control = control_coxreg(interaction = TRUE), - na_level = "---" - ), - "The `na_level` argument" - )) }) testthat::test_that("summarize_coxreg works without treatment arm in univariate case", { From 495c01adbe164eec746e6bd2fb8465a240b1bbc2 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 15:34:15 -0400 Subject: [PATCH 02/10] summary_custom (0.9.0) --- NAMESPACE | 1 - NEWS.md | 4 +- R/utils_default_stats_formats_labels.R | 66 ------------- _pkgdown.yml | 1 - man/default_stats_formats_labels.Rd | 45 --------- .../utils_default_stats_formats_labels.md | 92 ------------------- .../test-utils_default_stats_formats_labels.R | 14 --- 7 files changed, 3 insertions(+), 220 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 61c8df366d..9d0985983d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -284,7 +284,6 @@ export(summarize_occurrences_by_grade) export(summarize_patients_events_in_cols) export(summarize_patients_exposure_in_cols) export(summarize_vars) -export(summary_custom) export(summary_formats) export(summary_labels) export(surv_time) diff --git a/NEWS.md b/NEWS.md index dd35428909..ecf10b4b88 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,7 +18,9 @@ * Began deprecation of the named element `strat`, to be renamed to `strata`, within the `variables` argument to `h_rsp_to_logistic_variables`, `h_logistic_mult_cont_df`, `h_odds_ratio_subgroups_df`, `h_coxreg_mult_cont_df`, `h_coxph_subgroups_df`, `h_tbl_coxph_pairwise`, `extract_rsp_biomarkers`, `extract_rsp_subgroups`, `extract_survival_biomarkers`, and `extract_survival_subgroups`. * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. -* Remove all deprecated instances of the `na_level` parameter. +* Removed all instances of the deprecated `na_level` parameter. +* Removed all instances of the deprecated function `summary_custom`. + # tern 0.9.3 diff --git a/R/utils_default_stats_formats_labels.R b/R/utils_default_stats_formats_labels.R index 0580dd0c5a..c3b06816e6 100644 --- a/R/utils_default_stats_formats_labels.R +++ b/R/utils_default_stats_formats_labels.R @@ -522,69 +522,3 @@ summary_labels <- function(type = "numeric", include_pval = FALSE) { met_grp <- paste0(c("analyze_vars", type), collapse = "_") get_labels_from_stats(get_stats(met_grp, add_pval = include_pval)) } - -#' @describeIn default_stats_formats_labels `r lifecycle::badge("deprecated")` Function to -#' configure settings for default or custom summary statistics for a given data type. In -#' addition to selecting a custom subset of statistics, the user can also set custom -#' formats, labels, and indent modifiers for any of these statistics. -#' -#' @param stats_custom (`named vector` of `character`)\cr vector of statistics to include if -#' not the defaults. This argument overrides `include_pval` and other custom value arguments -#' such that only settings for these statistics will be returned. -#' @param formats_custom (`named vector` of `character`)\cr vector of custom statistics formats -#' to use in place of the defaults defined in [`summary_formats()`]. Names should be a subset -#' of the statistics defined in `stats_custom` (or default statistics if this is `NULL`). -#' @param labels_custom (`named vector` of `character`)\cr vector of custom statistics labels -#' to use in place of the defaults defined in [`summary_labels()`]. Names should be a subset -#' of the statistics defined in `stats_custom` (or default statistics if this is `NULL`). -#' @param indent_mods_custom (`integer` or `named vector` of `integer`)\cr vector of custom -#' indentation modifiers for statistics to use instead of the default of `0L` for all statistics. -#' Names should be a subset of the statistics defined in `stats_custom` (or default statistics -#' if this is `NULL`). Alternatively, the same indentation modifier can be applied to all -#' statistics by setting `indent_mods_custom` to a single integer value. -#' -#' @return -#' * `summary_custom` returns a `list` of 4 named elements: `stats`, `formats`, `labels`, -#' and `indent_mods`. -#' -#' @examples -#' summary_custom() -#' summary_custom(type = "counts", include_pval = TRUE) -#' summary_custom( -#' include_pval = TRUE, stats_custom = c("n", "mean", "sd", "pval"), -#' labels_custom = c(sd = "Std. Dev."), indent_mods_custom = 3L -#' ) -#' -#' @export -summary_custom <- function(type = "numeric", - include_pval = FALSE, - stats_custom = NULL, - formats_custom = NULL, - labels_custom = NULL, - indent_mods_custom = NULL) { - lifecycle::deprecate_warn( - "0.9.0.9001", - "summary_custom()", - details = "Please use `get_stats`, `get_formats_from_stats`, and `get_labels_from_stats` directly instead." - ) - met_grp <- paste0(c("analyze_vars", type), collapse = "_") - .stats <- get_stats(met_grp, stats_custom, add_pval = include_pval) - .formats <- get_formats_from_stats(.stats, formats_custom) - .labels <- get_labels_from_stats(.stats, labels_custom) - .indent_mods <- stats::setNames(rep(0L, length(.stats)), .stats) - - if (!is.null(indent_mods_custom)) { - if (is.null(names(indent_mods_custom)) && length(indent_mods_custom) == 1) { - .indent_mods[names(.indent_mods)] <- indent_mods_custom - } else { - .indent_mods[names(indent_mods_custom)] <- indent_mods_custom - } - } - - list( - stats = .stats, - formats = .formats, - labels = .labels, - indent_mods = .indent_mods[.stats] - ) -} diff --git a/_pkgdown.yml b/_pkgdown.yml index 7241190b4d..cc25a93133 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -190,4 +190,3 @@ reference: contents: - starts_with("create_") - summarize_vars - - summary_custom diff --git a/man/default_stats_formats_labels.Rd b/man/default_stats_formats_labels.Rd index 1c84fbea96..045eb1f41d 100644 --- a/man/default_stats_formats_labels.Rd +++ b/man/default_stats_formats_labels.Rd @@ -12,7 +12,6 @@ \alias{tern_default_labels} \alias{summary_formats} \alias{summary_labels} -\alias{summary_custom} \title{Get default statistical methods and their associated formats, labels, and indent modifiers} \format{ \itemize{ @@ -52,15 +51,6 @@ tern_default_labels summary_formats(type = "numeric", include_pval = FALSE) summary_labels(type = "numeric", include_pval = FALSE) - -summary_custom( - type = "numeric", - include_pval = FALSE, - stats_custom = NULL, - formats_custom = NULL, - labels_custom = NULL, - indent_mods_custom = NULL -) } \arguments{ \item{method_groups}{(\code{character})\cr indicates the statistical method group (\code{tern} analyze function) @@ -90,24 +80,6 @@ variable names if rows correspond to different variables instead of levels. Defa \item{type}{(\code{flag})\cr is it going to be \code{"numeric"} or \code{"counts"}?} \item{include_pval}{(\code{flag})\cr deprecated parameter. Same as \code{add_pval}.} - -\item{stats_custom}{(\verb{named vector} of \code{character})\cr vector of statistics to include if -not the defaults. This argument overrides \code{include_pval} and other custom value arguments -such that only settings for these statistics will be returned.} - -\item{formats_custom}{(\verb{named vector} of \code{character})\cr vector of custom statistics formats -to use in place of the defaults defined in \code{\link[=summary_formats]{summary_formats()}}. Names should be a subset -of the statistics defined in \code{stats_custom} (or default statistics if this is \code{NULL}).} - -\item{labels_custom}{(\verb{named vector} of \code{character})\cr vector of custom statistics labels -to use in place of the defaults defined in \code{\link[=summary_labels]{summary_labels()}}. Names should be a subset -of the statistics defined in \code{stats_custom} (or default statistics if this is \code{NULL}).} - -\item{indent_mods_custom}{(\code{integer} or \verb{named vector} of \code{integer})\cr vector of custom -indentation modifiers for statistics to use instead of the default of \code{0L} for all statistics. -Names should be a subset of the statistics defined in \code{stats_custom} (or default statistics -if this is \code{NULL}). Alternatively, the same indentation modifier can be applied to all -statistics by setting \code{indent_mods_custom} to a single integer value.} } \value{ \itemize{ @@ -137,11 +109,6 @@ or a named numeric vector of indent modifiers (if present, otherwise \code{NULL} \itemize{ \item \code{summary_labels} returns a named \code{vector} of default statistic labels for the given data type. } - -\itemize{ -\item \code{summary_custom} returns a \code{list} of 4 named elements: \code{stats}, \code{formats}, \code{labels}, -and \code{indent_mods}. -} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} @@ -177,11 +144,6 @@ group (analyze function). \item \code{summary_labels()}: Quick function to retrieve default labels for summary statistics. Returns labels of descriptive statistics which are understood by \code{rtables}. Similar to \code{summary_formats} -\item \code{summary_custom()}: \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Function to -configure settings for default or custom summary statistics for a given data type. In -addition to selecting a custom subset of statistics, the user can also set custom -formats, labels, and indent modifiers for any of these statistics. - }} \note{ These defaults are experimental because we use the names of functions to retrieve the default @@ -239,13 +201,6 @@ summary_formats(type = "counts", include_pval = TRUE) summary_labels() summary_labels(type = "counts", include_pval = TRUE) -summary_custom() -summary_custom(type = "counts", include_pval = TRUE) -summary_custom( - include_pval = TRUE, stats_custom = c("n", "mean", "sd", "pval"), - labels_custom = c(sd = "Std. Dev."), indent_mods_custom = 3L -) - } \seealso{ \link{formatting_functions} diff --git a/tests/testthat/_snaps/utils_default_stats_formats_labels.md b/tests/testthat/_snaps/utils_default_stats_formats_labels.md index 9beb511606..fb13d7d35c 100644 --- a/tests/testthat/_snaps/utils_default_stats_formats_labels.md +++ b/tests/testthat/_snaps/utils_default_stats_formats_labels.md @@ -141,95 +141,3 @@ n_blq pval_counts "n_blq" "p-value (chi-squared test)" -# summary_custom works as expected - - Code - res - Output - $stats - [1] "n" "sum" "mean" "sd" "se" - [6] "mean_sd" "mean_se" "mean_ci" "mean_sei" "mean_sdi" - [11] "mean_pval" "median" "mad" "median_ci" "quantiles" - [16] "iqr" "range" "min" "max" "median_range" - [21] "cv" "geom_mean" "geom_mean_ci" "geom_cv" - - $formats - n sum mean - "xx." "xx.x" "xx.x" - sd se mean_sd - "xx.x" "xx.x" "xx.x (xx.x)" - mean_se mean_ci mean_sei - "xx.x (xx.x)" "(xx.xx, xx.xx)" "(xx.xx, xx.xx)" - mean_sdi mean_pval median - "(xx.xx, xx.xx)" "x.xxxx | (<0.0001)" "xx.x" - mad median_ci quantiles - "xx.x" "(xx.xx, xx.xx)" "xx.x - xx.x" - iqr range min - "xx.x" "xx.x - xx.x" "xx.x" - max median_range cv - "xx.x" "xx.x (xx.x - xx.x)" "xx.x" - geom_mean geom_mean_ci geom_cv - "xx.x" "(xx.xx, xx.xx)" "xx.x" - - $labels - n sum - "n" "Sum" - mean sd - "Mean" "SD" - se mean_sd - "SE" "Mean (SD)" - mean_se mean_ci - "Mean (SE)" "Mean 95% CI" - mean_sei mean_sdi - "Mean -/+ 1xSE" "Mean -/+ 1xSD" - mean_pval median - "Mean p-value (H0: mean = 0)" "Median" - mad median_ci - "Median Absolute Deviation" "Median 95% CI" - quantiles iqr - "25% and 75%-ile" "IQR" - range min - "Min - Max" "Minimum" - max median_range - "Maximum" "Median (Min - Max)" - cv geom_mean - "CV (%)" "Geometric Mean" - geom_mean_ci geom_cv - "Geometric Mean 95% CI" "CV % Geometric Mean" - - $indent_mods - n sum mean sd se mean_sd - 0 0 0 0 0 0 - mean_se mean_ci mean_sei mean_sdi mean_pval median - 0 0 0 0 0 0 - mad median_ci quantiles iqr range min - 0 0 0 0 0 0 - max median_range cv geom_mean geom_mean_ci geom_cv - 0 0 0 0 0 0 - - ---- - - Code - res - Output - $stats - [1] "n" "count" - - $formats - $formats$n - [1] "xx.xx" - - $formats$count - [1] "xx." - - - $labels - n count - "n" "#" - - $indent_mods - n count - 2 2 - - diff --git a/tests/testthat/test-utils_default_stats_formats_labels.R b/tests/testthat/test-utils_default_stats_formats_labels.R index d9c6afb817..4c1fb12378 100644 --- a/tests/testthat/test-utils_default_stats_formats_labels.R +++ b/tests/testthat/test-utils_default_stats_formats_labels.R @@ -218,17 +218,3 @@ testthat::test_that("summary_labels works as expected", { res <- testthat::expect_silent(result) testthat::expect_snapshot(res) }) - -# Deprecated -testthat::test_that("summary_custom works as expected", { - testthat::expect_warning(res <- summary_custom()) - res$formats <- unlist(res$formats) - testthat::expect_snapshot(res) - - testthat::expect_warning(res <- summary_custom( - type = "counts", stats_custom = c("n", "count"), - formats_custom = c(n = "xx.xx"), labels_custom = c(count = "#"), indent_mods_custom = 2L - )) - - testthat::expect_snapshot(res) -}) From 2fa17620c8d7d2fa2749e3183c5a21dbec30712e Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 15:42:53 -0400 Subject: [PATCH 03/10] a_compare (0.8.3) --- NAMESPACE | 1 - NEWS.md | 2 +- R/analyze_variables.R | 1 + R/compare_variables.R | 42 ++----------------------- man/compare_variables.Rd | 34 +------------------- tests/testthat/test-compare_variables.R | 9 ------ 6 files changed, 5 insertions(+), 84 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9d0985983d..8b56c19773 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,7 +21,6 @@ S3method(tidy,glm) S3method(tidy,step) S3method(tidy,summary.coxph) export(CombinationFunction) -export(a_compare) export(a_count_occurrences) export(a_count_occurrences_by_grade) export(a_count_patients_sum_exposure) diff --git a/NEWS.md b/NEWS.md index ecf10b4b88..044c7624bd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,7 +19,7 @@ * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. * Removed all instances of the deprecated `na_level` parameter. -* Removed all instances of the deprecated function `summary_custom`. +* Removed deprecated functions `a_compare` and `summary_custom`. # tern 0.9.3 diff --git a/R/analyze_variables.R b/R/analyze_variables.R index 9fe2c1b789..7bb77f670f 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -482,6 +482,7 @@ a_summary <- function(x, na.rm = TRUE, # nolint na_str = default_na_str(), ...) { + extra_args <- list(...) if (is.numeric(x)) { type <- "numeric" if (!is.null(.stats) && any(grepl("^pval", .stats))) { diff --git a/R/compare_variables.R b/R/compare_variables.R index 3902bbb174..1b651827ef 100644 --- a/R/compare_variables.R +++ b/R/compare_variables.R @@ -25,7 +25,7 @@ #' is well defined. #' #' @seealso Relevant constructor function [create_afun_compare()], [s_summary()] which is used internally -#' to compute a summary within `s_compare()`, and [a_compare()] which is used (with `compare = TRUE`) as the analysis +#' to compute a summary within `s_compare()`, and [a_summary()] which is used (with `compare = TRUE`) as the analysis #' function for `compare_vars()`. #' #' @name compare_variables @@ -250,45 +250,6 @@ s_compare.logical <- function(x, y } -#' @describeIn compare_variables Formatted analysis function which is used as `afun` -#' in `compare_vars()`. -#' -#' @return -#' * `a_compare()` returns the corresponding list with formatted [rtables::CellValue()]. -#' -#' @note `a_compare()` has been deprecated in favor of `a_summary()` with argument `compare` set to `TRUE`. -#' -#' @examples -#' # `a_compare` deprecated - use `a_summary()` instead -#' a_compare(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval")) -#' -#' @export -a_compare <- function(x, - .N_col, # nolint - .N_row, # nolint - .var = NULL, - .df_row = NULL, - .ref_group = NULL, - .in_ref_col = FALSE, - ...) { - lifecycle::deprecate_warn( - "0.8.3", - "a_compare()", - details = "Please use a_summary() with argument `compare` set to TRUE instead." - ) - a_summary( - x = x, - .N_col = .N_col, - .N_row = .N_row, - .var = .var, - .df_row = .df_row, - .ref_group = .ref_group, - .in_ref_col = .in_ref_col, - compare = TRUE, - ... - ) -} - #' Constructor Function for [compare_vars()] #' #' @description `r lifecycle::badge("deprecated")` @@ -385,6 +346,7 @@ compare_vars <- function(lyt, .labels = NULL, .indent_mods = NULL) { extra_args <- list(.stats = .stats, na.rm = na.rm, na_str = na_str, compare = TRUE, ...) + if (!is.null(.formats)) extra_args[[".formats"]] <- .formats if (!is.null(.labels)) extra_args[[".labels"]] <- .labels if (!is.null(.indent_mods)) extra_args[[".indent_mods"]] <- .indent_mods diff --git a/man/compare_variables.Rd b/man/compare_variables.Rd index 2b8dc276f5..94684cc59a 100644 --- a/man/compare_variables.Rd +++ b/man/compare_variables.Rd @@ -8,7 +8,6 @@ \alias{s_compare.factor} \alias{s_compare.character} \alias{s_compare.logical} -\alias{a_compare} \title{Compare Variables Between Groups} \usage{ compare_vars( @@ -46,17 +45,6 @@ s_compare(x, .ref_group, .in_ref_col, ...) ) \method{s_compare}{logical}(x, .ref_group, .in_ref_col, na.rm = TRUE, denom = "n", ...) - -a_compare( - x, - .N_col, - .N_row, - .var = NULL, - .df_row = NULL, - .ref_group = NULL, - .in_ref_col = FALSE, - ... -) } \arguments{ \item{lyt}{(\code{layout})\cr input layout where analyses will be added to.} @@ -110,14 +98,6 @@ by a statistics function.} \item{verbose}{(\code{logical})\cr Whether warnings and messages should be printed. Mainly used to print out information about factor casting. Defaults to \code{TRUE}.} - -\item{.N_col}{(\code{integer})\cr column-wise N (column count) for the full column being analyzed that is typically -passed by \code{rtables}.} - -\item{.N_row}{(\code{integer})\cr row-wise N (row group count) for the group of observations being analyzed -(i.e. with no column-based subsetting) that is typically passed by \code{rtables}.} - -\item{.df_row}{(\code{data.frame})\cr data frame across all of the columns for the given row split.} } \value{ \itemize{ @@ -129,10 +109,6 @@ the statistics from \code{s_compare()} to the table layout. \itemize{ \item \code{s_compare()} returns output of \code{\link[=s_summary]{s_summary()}} and comparisons versus the reference group in the form of p-values. } - -\itemize{ -\item \code{a_compare()} returns the corresponding list with formatted \code{\link[rtables:CellValue]{rtables::CellValue()}}. -} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}} @@ -158,9 +134,6 @@ conversion to \code{factor} (with a warning) and then forwards to the method for \item \code{s_compare(logical)}: Method for \code{logical} class. A chi-squared test is used. If missing values are not removed, then they are counted as \code{FALSE}. -\item \code{a_compare()}: Formatted analysis function which is used as \code{afun} -in \code{compare_vars()}. - }} \note{ \itemize{ @@ -178,8 +151,6 @@ Therefore it is always better to manually convert character variables to factors \item For \code{compare_vars()}, the column split must define a reference group via \code{ref_group} so that the comparison is well defined. } - -\code{a_compare()} has been deprecated in favor of \code{a_summary()} with argument \code{compare} set to \code{TRUE}. } \examples{ # `compare_vars()` in `rtables` pipelines @@ -257,12 +228,9 @@ y <- c(NA, NA, NA, NA, FALSE) s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = TRUE) s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = FALSE) -# `a_compare` deprecated - use `a_summary()` instead -a_compare(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval")) - } \seealso{ Relevant constructor function \code{\link[=create_afun_compare]{create_afun_compare()}}, \code{\link[=s_summary]{s_summary()}} which is used internally -to compute a summary within \code{s_compare()}, and \code{\link[=a_compare]{a_compare()}} which is used (with \code{compare = TRUE}) as the analysis +to compute a summary within \code{s_compare()}, and \code{\link[=a_summary]{a_summary()}} which is used (with \code{compare = TRUE}) as the analysis function for \code{compare_vars()}. } diff --git a/tests/testthat/test-compare_variables.R b/tests/testthat/test-compare_variables.R index 8e56125e88..cb70635c24 100644 --- a/tests/testthat/test-compare_variables.R +++ b/tests/testthat/test-compare_variables.R @@ -130,12 +130,3 @@ testthat::test_that("compare_vars 'na_str' argument works as expected", { testthat::test_that("create_afun_compare returns error message", { testthat::expect_warning(create_afun_compare()) # before It was not covered directly }) - -testthat::test_that("a_compare returns correct output and warning message", { - testthat::expect_warning({ - result <- a_compare(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval")) - }) - expected <- a_summary(rnorm(10, 5, 1), .ref_group = rnorm(20, -5, 1), .stats = c("n", "pval"), compare = TRUE) - - testthat::expect_equal(result, expected) -}) From b2c5e5987505626d1ac8d4d6eea796b422d70045 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 15:46:52 -0400 Subject: [PATCH 04/10] create_afun_summary, create_afun_compare (0.8.3) --- NAMESPACE | 2 - NEWS.md | 2 +- R/analyze_variables.R | 41 -------------------- R/compare_variables.R | 51 +------------------------ _pkgdown.yml | 1 - man/compare_variables.Rd | 5 +-- man/create_afun_compare.Rd | 40 ------------------- man/create_afun_summary.Rd | 34 ----------------- tests/testthat/test-analyze_variables.R | 26 ------------- tests/testthat/test-compare_variables.R | 6 --- 10 files changed, 5 insertions(+), 203 deletions(-) delete mode 100644 man/create_afun_compare.Rd delete mode 100644 man/create_afun_summary.Rd diff --git a/NAMESPACE b/NAMESPACE index 8b56c19773..d8783d22ee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -72,8 +72,6 @@ export(count_patients_with_event) export(count_patients_with_flags) export(count_values) export(coxph_pairwise) -export(create_afun_compare) -export(create_afun_summary) export(cut_quantile_bins) export(d_count_abnormal_by_baseline) export(d_count_cumulative) diff --git a/NEWS.md b/NEWS.md index 044c7624bd..68bb2f4654 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,7 +19,7 @@ * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. * Removed all instances of the deprecated `na_level` parameter. -* Removed deprecated functions `a_compare` and `summary_custom`. +* Removed deprecated functions `a_compare`, `create_afun_summary`, `create_afun_compare`, and `summary_custom`. # tern 0.9.3 diff --git a/R/analyze_variables.R b/R/analyze_variables.R index 7bb77f670f..a37f3a3375 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -545,47 +545,6 @@ a_summary <- function(x, ) } -#' Constructor Function for [analyze_vars()] and [summarize_colvars()] -#' -#' @description `r lifecycle::badge("deprecated")` -#' -#' Constructor function which creates a combined formatted analysis function. -#' -#' @inheritParams argument_convention -#' @param .indent_mods (named `vector` of `integer`)\cr indent modifiers for the labels. Each element of the vector -#' should be a name-value pair with name corresponding to a statistic specified in `.stats` and value the indentation -#' for that statistic's row label. -#' -#' @return Combined formatted analysis function for use in [analyze_vars()]. -#' -#' @note This function has been deprecated in favor of direct implementation of `a_summary()`. -#' -#' @seealso [analyze_vars()] -#' -#' @export -create_afun_summary <- function(.stats, .formats, .labels, .indent_mods) { - lifecycle::deprecate_warn( - "0.8.5.9010", - "create_afun_summary()", - details = "Please use a_summary() directly instead." - ) - function(x, - .ref_group, - .in_ref_col, - ..., - .var) { - a_summary(x, - .stats = .stats, - .formats = .formats, - .labels = .labels, - .indent_mods = .indent_mods, - .ref_group = .ref_group, - .in_ref_col = .in_ref_col, - .var = .var, ... - ) - } -} - #' @describeIn analyze_variables Layout-creating function which can take statistics function arguments #' and additional format arguments. This function is a wrapper for [rtables::analyze()]. #' diff --git a/R/compare_variables.R b/R/compare_variables.R index 1b651827ef..3a6c9539d9 100644 --- a/R/compare_variables.R +++ b/R/compare_variables.R @@ -24,9 +24,8 @@ #' * For `compare_vars()`, the column split must define a reference group via `ref_group` so that the comparison #' is well defined. #' -#' @seealso Relevant constructor function [create_afun_compare()], [s_summary()] which is used internally -#' to compute a summary within `s_compare()`, and [a_summary()] which is used (with `compare = TRUE`) as the analysis -#' function for `compare_vars()`. +#' @seealso [s_summary()] which is used internally to compute a summary within `s_compare()`, and [a_summary()] +#' which is used (with `compare = TRUE`) as the analysis function for `compare_vars()`. #' #' @name compare_variables #' @include analyze_variables.R @@ -250,52 +249,6 @@ s_compare.logical <- function(x, y } -#' Constructor Function for [compare_vars()] -#' -#' @description `r lifecycle::badge("deprecated")` -#' -#' Constructor function which creates a combined formatted analysis function. -#' -#' @inheritParams argument_convention -#' @param .indent_mods (named `vector` of `integer`)\cr indent modifiers for the labels. Each element of the vector -#' should be a name-value pair with name corresponding to a statistic specified in `.stats` and value the indentation -#' for that statistic's row label. -#' -#' @return Combined formatted analysis function for use in [compare_vars()]. -#' -#' @note This function has been deprecated in favor of direct implementation of `a_summary()` with argument `compare` -#' set to `TRUE`. -#' -#' @seealso [compare_vars()] -#' -#' @export -create_afun_compare <- function(.stats = NULL, - .formats = NULL, - .labels = NULL, - .indent_mods = NULL) { - lifecycle::deprecate_warn( - "0.8.5.9010", - "create_afun_compare()", - details = "Please use a_summary(compare = TRUE) directly instead." - ) - function(x, - .ref_group, - .in_ref_col, - ..., - .var) { - a_summary(x, - compare = TRUE, - .stats = .stats, - .formats = .formats, - .labels = .labels, - .indent_mods = .indent_mods, - .ref_group = .ref_group, - .in_ref_col = .in_ref_col, - .var = .var, ... - ) - } -} - #' @describeIn compare_variables Layout-creating function which can take statistics function arguments #' and additional format arguments. This function is a wrapper for [rtables::analyze()]. #' diff --git a/_pkgdown.yml b/_pkgdown.yml index cc25a93133..6519eb45eb 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -188,5 +188,4 @@ reference: - title: Deprecated Functions desc: Functions that are currently deprecated within `tern`. contents: - - starts_with("create_") - summarize_vars diff --git a/man/compare_variables.Rd b/man/compare_variables.Rd index 94684cc59a..fa2bd8dced 100644 --- a/man/compare_variables.Rd +++ b/man/compare_variables.Rd @@ -230,7 +230,6 @@ s_compare(x, .ref_group = y, .in_ref_col = FALSE, na.rm = FALSE) } \seealso{ -Relevant constructor function \code{\link[=create_afun_compare]{create_afun_compare()}}, \code{\link[=s_summary]{s_summary()}} which is used internally -to compute a summary within \code{s_compare()}, and \code{\link[=a_summary]{a_summary()}} which is used (with \code{compare = TRUE}) as the analysis -function for \code{compare_vars()}. +\code{\link[=s_summary]{s_summary()}} which is used internally to compute a summary within \code{s_compare()}, and \code{\link[=a_summary]{a_summary()}} +which is used (with \code{compare = TRUE}) as the analysis function for \code{compare_vars()}. } diff --git a/man/create_afun_compare.Rd b/man/create_afun_compare.Rd deleted file mode 100644 index 0c7c0feb21..0000000000 --- a/man/create_afun_compare.Rd +++ /dev/null @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compare_variables.R -\name{create_afun_compare} -\alias{create_afun_compare} -\title{Constructor Function for \code{\link[=compare_vars]{compare_vars()}}} -\usage{ -create_afun_compare( - .stats = NULL, - .formats = NULL, - .labels = NULL, - .indent_mods = NULL -) -} -\arguments{ -\item{.stats}{(\code{character})\cr statistics to select for the table.} - -\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.} - -\item{.labels}{(named \code{character})\cr labels for the statistics (without indent).} - -\item{.indent_mods}{(named \code{vector} of \code{integer})\cr indent modifiers for the labels. Each element of the vector -should be a name-value pair with name corresponding to a statistic specified in \code{.stats} and value the indentation -for that statistic's row label.} -} -\value{ -Combined formatted analysis function for use in \code{\link[=compare_vars]{compare_vars()}}. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -Constructor function which creates a combined formatted analysis function. -} -\note{ -This function has been deprecated in favor of direct implementation of \code{a_summary()} with argument \code{compare} -set to \code{TRUE}. -} -\seealso{ -\code{\link[=compare_vars]{compare_vars()}} -} diff --git a/man/create_afun_summary.Rd b/man/create_afun_summary.Rd deleted file mode 100644 index bf66f7fa42..0000000000 --- a/man/create_afun_summary.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/analyze_variables.R -\name{create_afun_summary} -\alias{create_afun_summary} -\title{Constructor Function for \code{\link[=analyze_vars]{analyze_vars()}} and \code{\link[=summarize_colvars]{summarize_colvars()}}} -\usage{ -create_afun_summary(.stats, .formats, .labels, .indent_mods) -} -\arguments{ -\item{.stats}{(\code{character})\cr statistics to select for the table.} - -\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.} - -\item{.labels}{(named \code{character})\cr labels for the statistics (without indent).} - -\item{.indent_mods}{(named \code{vector} of \code{integer})\cr indent modifiers for the labels. Each element of the vector -should be a name-value pair with name corresponding to a statistic specified in \code{.stats} and value the indentation -for that statistic's row label.} -} -\value{ -Combined formatted analysis function for use in \code{\link[=analyze_vars]{analyze_vars()}}. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -Constructor function which creates a combined formatted analysis function. -} -\note{ -This function has been deprecated in favor of direct implementation of \code{a_summary()}. -} -\seealso{ -\code{\link[=analyze_vars]{analyze_vars()}} -} diff --git a/tests/testthat/test-analyze_variables.R b/tests/testthat/test-analyze_variables.R index afd4f3ef0b..3c10fd1012 100644 --- a/tests/testthat/test-analyze_variables.R +++ b/tests/testthat/test-analyze_variables.R @@ -507,32 +507,6 @@ testthat::test_that("control_analyze_vars fails wrong inputs", { testthat::expect_error(control_analyze_vars(conf_level = 95)) }) -# Deprecated functions ------ -testthat::test_that("create_afun_summary creates an `afun` that works and throws a warning", { - testthat::expect_warning(afun <- create_afun_summary( - .stats = c("n", "count_fraction", "median", "range", "mean_ci"), - .formats = c(median = "xx."), - .labels = c(median = "My median"), - .indent_mods = c(median = 1L) - )) - dta_test <- data.frame( - USUBJID = rep(1:6, each = 3), - PARAMCD = rep("lab", 6 * 3), - AVISIT = rep(paste0("V", 1:3), 6), - ARM = rep(LETTERS[1:3], rep(6, 3)), - AVAL = c(9:1, rep(NA, 9)), - stringsAsFactors = TRUE - ) - - l <- basic_table() %>% - split_cols_by(var = "ARM") %>% - split_rows_by(var = "AVISIT") %>% - analyze(vars = c("AVAL", "ARM"), afun = afun) - - # From visual inspection it works as before, same output - testthat::expect_silent(result <- build_table(l, df = dta_test)) -}) - testthat::test_that("analyze_vars works correctly with auto formats", { dt <- data.frame("VAR" = c(0.001, 0.2, 0.0011000, 3, 4)) res <- basic_table() %>% diff --git a/tests/testthat/test-compare_variables.R b/tests/testthat/test-compare_variables.R index cb70635c24..7a5d44f298 100644 --- a/tests/testthat/test-compare_variables.R +++ b/tests/testthat/test-compare_variables.R @@ -124,9 +124,3 @@ testthat::test_that("compare_vars 'na_str' argument works as expected", { res <- testthat::expect_silent(result) testthat::expect_snapshot(res) }) - -# Deprecated functions - -testthat::test_that("create_afun_compare returns error message", { - testthat::expect_warning(create_afun_compare()) # before It was not covered directly -}) From 82351cc589810e7632658c6419a37b13ca3f877a Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 15:50:57 -0400 Subject: [PATCH 05/10] indent_mod parameter (0.8.2) --- NEWS.md | 2 +- R/argument_convention.R | 1 - R/summarize_num_patients.R | 12 ------------ man/argument_convention.Rd | 2 -- man/summarize_num_patients.Rd | 4 ---- 5 files changed, 1 insertion(+), 20 deletions(-) diff --git a/NEWS.md b/NEWS.md index 68bb2f4654..0731e1f7a2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,7 +18,7 @@ * Began deprecation of the named element `strat`, to be renamed to `strata`, within the `variables` argument to `h_rsp_to_logistic_variables`, `h_logistic_mult_cont_df`, `h_odds_ratio_subgroups_df`, `h_coxreg_mult_cont_df`, `h_coxph_subgroups_df`, `h_tbl_coxph_pairwise`, `extract_rsp_biomarkers`, `extract_rsp_subgroups`, `extract_survival_biomarkers`, and `extract_survival_subgroups`. * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. -* Removed all instances of the deprecated `na_level` parameter. +* Removed all instances of the deprecated parameters `na_level` and `indent_mod`. * Removed deprecated functions `a_compare`, `create_afun_summary`, `create_afun_compare`, and `summary_custom`. diff --git a/R/argument_convention.R b/R/argument_convention.R index 70efc82e19..64121a6a7f 100644 --- a/R/argument_convention.R +++ b/R/argument_convention.R @@ -37,7 +37,6 @@ #' levels that belong to it in the character vectors that are elements of the list. #' @param id (`string`)\cr subject variable name. #' @param is_event (`logical`)\cr `TRUE` if event, `FALSE` if time to event is censored. -#' @param indent_mod `r lifecycle::badge("deprecated")` Please use the `.indent_mods` argument instead. #' @param label_all (`string`)\cr label for the total population analysis. #' @param labelstr (`character`)\cr label of the level of the parent split currently being summarized #' (must be present as second argument in Content Row Functions). See [rtables::summarize_row_groups()] diff --git a/R/summarize_num_patients.R b/R/summarize_num_patients.R index 21617a1fc3..ee0a40486d 100644 --- a/R/summarize_num_patients.R +++ b/R/summarize_num_patients.R @@ -150,17 +150,11 @@ summarize_num_patients <- function(lyt, unique = "Number of patients with at least one event", nonunique = "Number of events" ), - indent_mod = lifecycle::deprecated(), .indent_mods = 0L, riskdiff = FALSE, ...) { checkmate::assert_flag(riskdiff) - if (lifecycle::is_present(indent_mod)) { - lifecycle::deprecate_warn("0.8.2", "summarize_num_patients(indent_mod)", "summarize_num_patients(.indent_mods)") - .indent_mods <- indent_mod - } - if (is.null(.stats)) .stats <- c("unique", "nonunique", "unique_count") if (length(.labels) > length(.stats)) .labels <- .labels[names(.labels) %in% .stats] @@ -242,17 +236,11 @@ analyze_num_patients <- function(lyt, nonunique = "Number of events" ), show_labels = c("default", "visible", "hidden"), - indent_mod = lifecycle::deprecated(), .indent_mods = 0L, riskdiff = FALSE, ...) { checkmate::assert_flag(riskdiff) - if (lifecycle::is_present(indent_mod)) { - lifecycle::deprecate_warn("0.8.2", "analyze_num_patients(indent_mod)", "analyze_num_patients(.indent_mods)") - .indent_mods <- indent_mod - } - if (is.null(.stats)) .stats <- c("unique", "nonunique", "unique_count") if (length(.labels) > length(.stats)) .labels <- .labels[names(.labels) %in% .stats] diff --git a/man/argument_convention.Rd b/man/argument_convention.Rd index 44ae90c2f7..48b726a0fe 100644 --- a/man/argument_convention.Rd +++ b/man/argument_convention.Rd @@ -61,8 +61,6 @@ levels that belong to it in the character vectors that are elements of the list. \item{is_event}{(\code{logical})\cr \code{TRUE} if event, \code{FALSE} if time to event is censored.} -\item{indent_mod}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{.indent_mods} argument instead.} - \item{label_all}{(\code{string})\cr label for the total population analysis.} \item{labelstr}{(\code{character})\cr label of the level of the parent split currently being summarized diff --git a/man/summarize_num_patients.Rd b/man/summarize_num_patients.Rd index 266317024d..0c9684a210 100644 --- a/man/summarize_num_patients.Rd +++ b/man/summarize_num_patients.Rd @@ -20,7 +20,6 @@ analyze_num_patients( .labels = c(unique = "Number of patients with at least one event", nonunique = "Number of events"), show_labels = c("default", "visible", "hidden"), - indent_mod = lifecycle::deprecated(), .indent_mods = 0L, riskdiff = FALSE, ... @@ -37,7 +36,6 @@ summarize_num_patients( .formats = NULL, .labels = c(unique = "Number of patients with at least one event", nonunique = "Number of events"), - indent_mod = lifecycle::deprecated(), .indent_mods = 0L, riskdiff = FALSE, ... @@ -90,8 +88,6 @@ information on the \code{"auto"} setting.} \item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} -\item{indent_mod}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{.indent_mods} argument instead.} - \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.} From 5e466cb53c730415dcaff5e45231e08cf41e056f Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 15:54:16 -0400 Subject: [PATCH 06/10] time_unit_input, time_unit_output parameters (0.8.3) --- NEWS.md | 3 +-- R/control_incidence_rate.R | 19 +------------------ man/control_incidence_rate.Rd | 8 +------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0731e1f7a2..708ce73869 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,10 +18,9 @@ * Began deprecation of the named element `strat`, to be renamed to `strata`, within the `variables` argument to `h_rsp_to_logistic_variables`, `h_logistic_mult_cont_df`, `h_odds_ratio_subgroups_df`, `h_coxreg_mult_cont_df`, `h_coxph_subgroups_df`, `h_tbl_coxph_pairwise`, `extract_rsp_biomarkers`, `extract_rsp_subgroups`, `extract_survival_biomarkers`, and `extract_survival_subgroups`. * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. -* Removed all instances of the deprecated parameters `na_level` and `indent_mod`. +* Removed all instances of deprecated parameters `time_unit_input`, `time_unit_output`, `na_level` and `indent_mod`. * Removed deprecated functions `a_compare`, `create_afun_summary`, `create_afun_compare`, and `summary_custom`. - # tern 0.9.3 ### New Features diff --git a/R/control_incidence_rate.R b/R/control_incidence_rate.R index 75f6a3b5e0..e912cf84b9 100644 --- a/R/control_incidence_rate.R +++ b/R/control_incidence_rate.R @@ -11,8 +11,6 @@ #' @param input_time_unit (`string`)\cr `day`, `week`, `month`, or `year` (default) #' indicating time unit for data input. #' @param num_pt_year (`numeric`)\cr number of patient-years to use when calculating adverse event rates. -#' @param time_unit_input `r lifecycle::badge("deprecated")` Please use the `input_time_unit` argument instead. -#' @param time_unit_output `r lifecycle::badge("deprecated")` Please use the `num_pt_year` argument instead. #' #' @return A list of components with the same names as the arguments. #' @@ -25,22 +23,7 @@ control_incidence_rate <- function(conf_level = 0.95, conf_type = c("normal", "normal_log", "exact", "byar"), input_time_unit = c("year", "day", "week", "month"), - num_pt_year = 100, - time_unit_input = lifecycle::deprecated(), - time_unit_output = lifecycle::deprecated()) { - if (lifecycle::is_present(time_unit_input)) { - lifecycle::deprecate_warn( - "0.8.3", "control_incidence_rate(time_unit_input)", "control_incidence_rate(input_time_unit)" - ) - input_time_unit <- time_unit_input - } - if (lifecycle::is_present(time_unit_output)) { - lifecycle::deprecate_warn( - "0.8.3", "control_incidence_rate(time_unit_output)", "control_incidence_rate(num_pt_year)" - ) - num_pt_year <- time_unit_output - } - + num_pt_year = 100) { conf_type <- match.arg(conf_type) input_time_unit <- match.arg(input_time_unit) checkmate::assert_number(num_pt_year) diff --git a/man/control_incidence_rate.Rd b/man/control_incidence_rate.Rd index 872f84c283..a4fcf188f4 100644 --- a/man/control_incidence_rate.Rd +++ b/man/control_incidence_rate.Rd @@ -8,9 +8,7 @@ control_incidence_rate( conf_level = 0.95, conf_type = c("normal", "normal_log", "exact", "byar"), input_time_unit = c("year", "day", "week", "month"), - num_pt_year = 100, - time_unit_input = lifecycle::deprecated(), - time_unit_output = lifecycle::deprecated() + num_pt_year = 100 ) } \arguments{ @@ -23,10 +21,6 @@ for confidence interval type.} indicating time unit for data input.} \item{num_pt_year}{(\code{numeric})\cr number of patient-years to use when calculating adverse event rates.} - -\item{time_unit_input}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{input_time_unit} argument instead.} - -\item{time_unit_output}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the \code{num_pt_year} argument instead.} } \value{ A list of components with the same names as the arguments. From 22c4bda31549896e57e2e5968ac407026c0e5974 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 16:06:23 -0400 Subject: [PATCH 07/10] summarize_vars, control_summarize_vars (0.8.5) --- NAMESPACE | 2 -- NEWS.md | 2 +- R/analyze_functions.R | 3 +-- R/analyze_variables.R | 21 ++------------------- _pkgdown.yml | 5 ----- man/analyze_functions.Rd | 3 +-- man/analyze_variables.Rd | 10 ---------- man/control_analyze_vars.Rd | 6 ------ tests/testthat/test-analyze_variables.R | 4 ++-- 9 files changed, 7 insertions(+), 49 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index d8783d22ee..386ea2b354 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -56,7 +56,6 @@ export(control_incidence_rate) export(control_lineplot_vars) export(control_logistic) export(control_step) -export(control_summarize_vars) export(control_surv_time) export(control_surv_timepoint) export(count_abnormal) @@ -280,7 +279,6 @@ export(summarize_occurrences) export(summarize_occurrences_by_grade) export(summarize_patients_events_in_cols) export(summarize_patients_exposure_in_cols) -export(summarize_vars) export(summary_formats) export(summary_labels) export(surv_time) diff --git a/NEWS.md b/NEWS.md index 708ce73869..a5dc94dc59 100644 --- a/NEWS.md +++ b/NEWS.md @@ -19,7 +19,7 @@ * Began deprecation of the `strat` argument to `s_coxph_pairwise` and replaced it with the `strata` argument. * Adapt to argument renames introduced in `ggplot2` 3.5.0. * Removed all instances of deprecated parameters `time_unit_input`, `time_unit_output`, `na_level` and `indent_mod`. -* Removed deprecated functions `a_compare`, `create_afun_summary`, `create_afun_compare`, and `summary_custom`. +* Removed deprecated functions `summarize_vars`, `control_summarize_vars`, `a_compare`, `create_afun_summary`, `create_afun_compare`, and `summary_custom`. # tern 0.9.3 diff --git a/R/analyze_functions.R b/R/analyze_functions.R index 20addfd507..d8b1c2fd28 100644 --- a/R/analyze_functions.R +++ b/R/analyze_functions.R @@ -32,8 +32,7 @@ #' leverage `analyze_colvars` to have the context split in rows and the analysis #' methods in columns. #' * [summarize_change()] -#' * [analyze_vars()]: formerly known as `summarize_vars()`, it was renamed to reflect -#' core function [rtables::analyze()]. +#' * [analyze_vars()] #' * [surv_time()] #' * [surv_timepoint()] #' * [test_proportion_diff()] diff --git a/R/analyze_variables.R b/R/analyze_variables.R index a37f3a3375..bb871eed30 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -12,14 +12,9 @@ #' This differs from R's default. See more about `type` in [stats::quantile()]. #' @param test_mean (`numeric`)\cr to test against the mean under the null hypothesis when calculating p-value. #' -#' @note Deprecation cycle started for `control_summarize_vars` as it is going to renamed into -#' `control_analyze_vars`. Intention is to reflect better the core underlying `rtables` -#' functions; in this case [analyze_vars()] wraps [rtables::analyze()]. -#' #' @return A list of components with the same names as the arguments. #' -#' @export control_analyze_vars control_summarize_vars -#' @aliases control_summarize_vars +#' @export control_analyze_vars <- function(conf_level = 0.95, quantiles = c(0.25, 0.75), quantile_type = 2, @@ -32,9 +27,6 @@ control_analyze_vars <- function(conf_level = 0.95, list(conf_level = conf_level, quantiles = quantiles, quantile_type = quantile_type, test_mean = test_mean) } -control_summarize_vars <- control_analyze_vars - - #' Analyze Variables #' #' @description `r lifecycle::badge("stable")` @@ -51,10 +43,6 @@ control_summarize_vars <- control_analyze_vars #' This utilizes the [format_auto()] formatting function. Note that only data for the current row & variable (for all #' columns) will be considered (`.df_row[[.var]]`, see [`rtables::additional_fun_params`]) and not the whole dataset. #' -#' @note -#' * Deprecation cycle started for `summarize_vars` which has been renamed to `analyze_vars`. This renaming is intended -#' to better reflect its core underlying `rtables` 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 @@ -617,7 +605,7 @@ a_summary <- function(x, #' ) %>% #' build_table(dt) #' -#' @export analyze_vars summarize_vars +#' @export #' @order 2 analyze_vars <- function(lyt, vars, @@ -652,8 +640,3 @@ analyze_vars <- function(lyt, section_div = section_div ) } -#' @describeIn analyze_variables `r lifecycle::badge("deprecated")` Use `analyze_vars` instead. -summarize_vars <- function(...) { - lifecycle::deprecate_warn(when = "0.8.5.9010", "summarize_vars()", "analyze_vars()") - analyze_vars(...) -} diff --git a/_pkgdown.yml b/_pkgdown.yml index 6519eb45eb..c62de9e18c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -184,8 +184,3 @@ reference: desc: Data included in the package. contents: - starts_with("ex_") - - - title: Deprecated Functions - desc: Functions that are currently deprecated within `tern`. - contents: - - summarize_vars diff --git a/man/analyze_functions.Rd b/man/analyze_functions.Rd index 14017aabc1..c334417366 100644 --- a/man/analyze_functions.Rd +++ b/man/analyze_functions.Rd @@ -34,8 +34,7 @@ variables that are split into different columns. In comparison, \link{analyze_co leverage \code{analyze_colvars} to have the context split in rows and the analysis methods in columns. \item \code{\link[=summarize_change]{summarize_change()}} -\item \code{\link[=analyze_vars]{analyze_vars()}}: formerly known as \code{summarize_vars()}, it was renamed to reflect -core function \code{\link[rtables:analyze]{rtables::analyze()}}. +\item \code{\link[=analyze_vars]{analyze_vars()}} \item \code{\link[=surv_time]{surv_time()}} \item \code{\link[=surv_timepoint]{surv_timepoint()}} \item \code{\link[=test_proportion_diff]{test_proportion_diff()}} diff --git a/man/analyze_variables.Rd b/man/analyze_variables.Rd index f361812933..242cc09d9f 100644 --- a/man/analyze_variables.Rd +++ b/man/analyze_variables.Rd @@ -9,7 +9,6 @@ \alias{s_summary.character} \alias{s_summary.logical} \alias{a_summary} -\alias{summarize_vars} \title{Analyze Variables} \usage{ analyze_vars( @@ -88,8 +87,6 @@ a_summary( na_str = default_na_str(), ... ) - -summarize_vars(...) } \arguments{ \item{lyt}{(\code{layout})\cr input layout where analyses will be added to.} @@ -268,15 +265,8 @@ conversion to factor (with a warning) and then forwards to the method for factor \item \code{a_summary()}: Formatted analysis function which is used as \code{afun} in \code{analyze_vars()} and \code{compare_vars()} and as \code{cfun} in \code{summarize_colvars()}. -\item \code{summarize_vars()}: \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{analyze_vars} instead. - }} \note{ -\itemize{ -\item Deprecation cycle started for \code{summarize_vars} which has been renamed to \code{analyze_vars}. This renaming is intended -to better reflect its core underlying \code{rtables} functions - in this case \code{\link[rtables:analyze]{rtables::analyze()}}. -} - \itemize{ \item If \code{x} is an empty vector, \code{NA} is returned. This is the expected feature so as to return \code{rcell} content in \code{rtables} when the intersection of a column and a row delimits an empty data selection. diff --git a/man/control_analyze_vars.Rd b/man/control_analyze_vars.Rd index 825166f5ec..5046612999 100644 --- a/man/control_analyze_vars.Rd +++ b/man/control_analyze_vars.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/analyze_variables.R \name{control_analyze_vars} \alias{control_analyze_vars} -\alias{control_summarize_vars} \title{Control Function for Descriptive Statistics} \usage{ control_analyze_vars( @@ -32,8 +31,3 @@ A list of components with the same names as the arguments. Sets a list of parameters for summaries of descriptive statistics. Typically used internally to specify details for \code{\link[=s_summary]{s_summary()}}. This function family is mainly used by \code{\link[=analyze_vars]{analyze_vars()}}. } -\note{ -Deprecation cycle started for \code{control_summarize_vars} as it is going to renamed into -\code{control_analyze_vars}. Intention is to reflect better the core underlying \code{rtables} -functions; in this case \code{\link[=analyze_vars]{analyze_vars()}} wraps \code{\link[rtables:analyze]{rtables::analyze()}}. -} diff --git a/tests/testthat/test-analyze_variables.R b/tests/testthat/test-analyze_variables.R index 3c10fd1012..f64d01f045 100644 --- a/tests/testthat/test-analyze_variables.R +++ b/tests/testthat/test-analyze_variables.R @@ -221,7 +221,7 @@ testthat::test_that("a_summary works with custom input.", { options("width" = 100) result <- a_summary( rnorm(10), - .N_col = 10, .N_row = 20, control_summarize_vars(conf_level = 0.90), .stats = c("sd", "median_ci"), + .N_col = 10, .N_row = 20, control_analyze_vars(conf_level = 0.90), .stats = c("sd", "median_ci"), .formats = c(sd = "xx.", median_ci = "xx.xx - xx.xx"), .labels = c(sd = "std. dev"), .indent_mods = 3L ) res <- testthat::expect_silent(result) @@ -267,7 +267,7 @@ testthat::test_that("a_summary works with custom input when compare = TRUE.", { options("width" = 100) result <- a_summary( rnorm(10), - .ref_group = rnorm(20, -5, 1), .N_col = 10, .N_row = 20, control_summarize_vars(conf_level = 0.90), + .ref_group = rnorm(20, -5, 1), .N_col = 10, .N_row = 20, control_analyze_vars(conf_level = 0.90), .stats = c("pval", "median_ci"), .formats = c(median_ci = "xx.xx - xx.xx"), .labels = c(pval = "pvalue"), .indent_mods = 3L, compare = TRUE ) From 7c4f12006ea2d85b817121f89015078021796e8b Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 16:26:33 -0400 Subject: [PATCH 08/10] Deprecate g_forest helpers --- NEWS.md | 1 + R/g_forest.R | 33 ++++++++++++++++++++++++++++++++- _pkgdown.yml | 8 +++++++- man/forest_viewport.Rd | 2 +- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index a5dc94dc59..7209b8a62b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,6 +20,7 @@ * Adapt to argument renames introduced in `ggplot2` 3.5.0. * Removed all instances of deprecated parameters `time_unit_input`, `time_unit_output`, `na_level` and `indent_mod`. * Removed deprecated functions `summarize_vars`, `control_summarize_vars`, `a_compare`, `create_afun_summary`, `create_afun_compare`, and `summary_custom`. +* Began deprecation of the `forest_grob`, `forest_dot_line`, `forest_viewport`, `vp_forest_table_part`, and `grid.forest` functions. # tern 0.9.3 diff --git a/R/g_forest.R b/R/g_forest.R index d6e1c2bfe6..4c3d55cd23 100644 --- a/R/g_forest.R +++ b/R/g_forest.R @@ -431,6 +431,8 @@ g_forest <- function(tbl, #' Forest Plot Grob #' +#' @description `r lifecycle::badge("deprecated")` +#' #' @inheritParams g_forest #' @param tbl ([rtables::rtable()]) #' @param x (`numeric`)\cr coordinate of point. @@ -488,6 +490,11 @@ forest_grob <- function(tbl, name = NULL, gp = NULL, vp = NULL) { + lifecycle::deprecate_warn( + "0.9.4", "forest_grob()", + details = "`g_forest` now generates `ggplot` objects. This function is no longer used within `tern`." + ) + nr <- nrow(tbl) if (is.null(vline)) { checkmate::assert_true(is.null(forest_header)) @@ -757,6 +764,8 @@ cell_in_rows <- function(row_name, #' Graphic Object: Forest Dot Line #' +#' @description `r lifecycle::badge("deprecated")` +#' #' Calculate the `grob` corresponding to the dot line within the forest plot. #' #' @noRd @@ -768,6 +777,11 @@ forest_dot_line <- function(x, symbol_size = 1, col = "blue", datavp) { + lifecycle::deprecate_warn( + "0.9.4", "forest_dot_line()", + details = "`g_forest` now generates `ggplot` objects. This function is no longer used within `tern`." + ) + ci <- c(lower, upper) if (any(!is.na(c(x, ci)))) { # line @@ -835,6 +849,9 @@ forest_dot_line <- function(x, } #' Create a Viewport Tree for the Forest Plot +#' +#' @description `r lifecycle::badge("deprecated")` +#' #' @param tbl (`rtable`) #' @param width_row_names (`grid::unit`)\cr Width of row names #' @param width_columns (`grid::unit`)\cr Width of column spans @@ -873,7 +890,7 @@ forest_viewport <- function(tbl, gap_header = grid::unit(1, "lines"), mat_form = NULL) { lifecycle::deprecate_warn( - "0.9.3", + "0.9.4", "forest_viewport()", details = "`g_forest` now generates `ggplot` objects. This function is no longer used within `tern`." ) @@ -951,6 +968,8 @@ forest_viewport <- function(tbl, #' Viewport Forest Plot: Table Part #' +#' @description `r lifecycle::badge("deprecated")` +#' #' Prepares a viewport for the table included in the forest plot. #' #' @noRd @@ -961,6 +980,11 @@ vp_forest_table_part <- function(nrow, widths, heights, name) { + lifecycle::deprecate_warn( + "0.9.4", "vp_forest_table_part()", + details = "`g_forest` now generates `ggplot` objects. This function is no longer used within `tern`." + ) + grid::vpTree( grid::viewport( name = name, @@ -1004,9 +1028,16 @@ vp_forest_table_part <- function(nrow, #' Forest Rendering #' +#' @description `r lifecycle::badge("deprecated")` +#' #' Renders the forest grob. #' #' @noRd grid.forest <- function(...) { # nolint + lifecycle::deprecate_warn( + "0.9.4", "grid.forest()", + details = "`g_forest` now generates `ggplot` objects. This function is no longer used within `tern`." + ) + grid::grid.draw(forest_grob(...)) } diff --git a/_pkgdown.yml b/_pkgdown.yml index c62de9e18c..51fe4a03df 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -150,7 +150,6 @@ reference: - h_g_ipp - matches(".*grob.*") - h_xticks - - forest_viewport - title: Data Helper Functions desc: These functions are used by other functions to derive data. @@ -184,3 +183,10 @@ reference: desc: Data included in the package. contents: - starts_with("ex_") + + + - title: Deprecated Functions + desc: Functions that are currently deprecated within `tern`. + contents: + - forest_viewport + diff --git a/man/forest_viewport.Rd b/man/forest_viewport.Rd index 9d09235da7..5455b91aec 100644 --- a/man/forest_viewport.Rd +++ b/man/forest_viewport.Rd @@ -33,7 +33,7 @@ forest_viewport( A viewport tree. } \description{ -Create a Viewport Tree for the Forest Plot +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \examples{ library(grid) From 3f794114bd3583da6a6d39d0dc4acda887c42260 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: Fri, 15 Mar 2024 20:33:05 +0000 Subject: [PATCH 09/10] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/to_string_matrix.Rd | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/man/to_string_matrix.Rd b/man/to_string_matrix.Rd index ee33f4b57a..0816f1fd02 100644 --- a/man/to_string_matrix.Rd +++ b/man/to_string_matrix.Rd @@ -16,18 +16,22 @@ to_string_matrix( \arguments{ \item{x}{\code{rtables} table.} -\item{widths}{(\code{numeric} or \code{NULL})\cr Proposed widths for the columns of \code{x}. The expected -length of this numeric vector can be retrieved with \code{ncol(x) + 1} as the column of row names -must also be considered.} - -\item{max_width}{(\code{integer(1)}, \code{character(1)} or \code{NULL})\cr width that title and footer (including -footnotes) materials should be word-wrapped to. If \code{NULL}, it is set to the current print width of the -session (\code{getOption("width")}). If set to \code{"auto"}, the width of the table (plus any table inset) is -used. Parameter is ignored if \code{tf_wrap = FALSE}.} - -\item{hsep}{(\code{character(1)})\cr character to repeat to create header/body separator line. If -\code{NULL}, the object value will be used. If \code{" "}, an empty separator will be printed. See -\code{\link[formatters:default_hsep]{default_hsep()}} for more information.} +\item{widths}{numeric (or \code{NULL}). (proposed) widths for the columns +of \code{x}. The expected length of this numeric vector can be +retrieved with \code{ncol() + 1} as the column of row names must +also be considered.} + +\item{max_width}{integer(1), character(1) or \code{NULL}. Width that title +and footer (including footnotes) materials should be +word-wrapped to. If \code{NULL}, it is set to the current print width +of the session (\code{getOption("width")}). If set to \code{"auto"}, +the width of the table (plus any table inset) is used. Ignored +completely if \code{tf_wrap} is \code{FALSE}.} + +\item{hsep}{character(1). Characters to repeat to create +header/body separator line. If \code{NULL}, the object value will be +used. If \code{" "}, an empty separator will be printed. Check \code{\link[formatters:default_hsep]{default_hsep()}} +for more information.} \item{with_spaces}{(\code{logical})\cr should the tested table keep the indentation and other relevant spaces?} From 155e4652cb84f8c675afcda29e2ed2d9d9dd6b19 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Fri, 15 Mar 2024 18:29:11 -0400 Subject: [PATCH 10/10] Empty commit