diff --git a/NEWS.md b/NEWS.md index b6f25d1a8c..8741fe4b01 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,15 +1,16 @@ # tern 0.8.5.9013 -### Miscellaneous -* Fix swapped descriptions for the `.N_row` and `.N_col` parameters. -* Fix bug in `analyze_vars_in_cols` when categorical data was used. -* Removal of internal calls to `df_explicit_na`. Changes in `NA` values should happen externally to `tern` functions, depending on users' needs. - ### Enhancements * Refactored `a_summary` to no longer use helper function `create_afun_summary`. * Refactored `summarize_vars` and `compare_vars` to use refactored `a_summary`. * Created new internal helper functions `ungroup_stats` to ungroup statistics calculated for factor variables, and `a_summary_internal` to perform calculations for `a_summary`. +### Miscellaneous +* Fix swapped descriptions for the `.N_row` and `.N_col` parameters. +* Fix bug in `analyze_vars_in_cols` when categorical data was used. +* Removal of internal calls to `df_explicit_na`. Changes in `NA` values should happen externally to `tern` functions, depending on users' needs. +* Reinstated correct soft deprecation for `create_afun_summary` and `create_afun_compare`. + # tern 0.8.5 ### Enhancements diff --git a/R/analyze_variables.R b/R/analyze_variables.R index 1f508a557d..d198ce999c 100644 --- a/R/analyze_variables.R +++ b/R/analyze_variables.R @@ -612,11 +612,26 @@ a_summary.numeric <- function(x, #' #' @export create_afun_summary <- function(.stats, .formats, .labels, .indent_mods) { - lifecycle::deprecate_stop( - "0.8.3", + 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 diff --git a/R/compare_variables.R b/R/compare_variables.R index 52bba6bf3d..44a2f85ff7 100644 --- a/R/compare_variables.R +++ b/R/compare_variables.R @@ -308,11 +308,27 @@ create_afun_compare <- function(.stats = NULL, .formats = NULL, .labels = NULL, .indent_mods = NULL) { - lifecycle::deprecate_stop( - "0.8.3", + 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 diff --git a/tests/testthat/test-analyze_variables.R b/tests/testthat/test-analyze_variables.R index 70d44f0914..505e04f09c 100644 --- a/tests/testthat/test-analyze_variables.R +++ b/tests/testthat/test-analyze_variables.R @@ -491,6 +491,27 @@ testthat::test_that("analyze_vars 'na_level' argument works as expected", { # Deprecated functions -testthat::test_that("create_afun_summary returns error message", { - testthat::expect_error(create_afun_summary()) +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)) }) diff --git a/tests/testthat/test-compare_variables.R b/tests/testthat/test-compare_variables.R index 6979f844b9..821e56cd52 100644 --- a/tests/testthat/test-compare_variables.R +++ b/tests/testthat/test-compare_variables.R @@ -128,7 +128,7 @@ testthat::test_that("compare_vars 'na_level' argument works as expected", { # Deprecated functions testthat::test_that("create_afun_compare returns error message", { - testthat::expect_error(create_afun_compare()) + testthat::expect_warning(create_afun_compare()) # before It was not covered directly }) testthat::test_that("a_compare returns correct output and warning message", {