diff --git a/NEWS.md b/NEWS.md index 40b12270d2..65abbdedf1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -60,8 +60,11 @@ memory consumption. (#2590) ### Phase 1 (message) - `derive_param_extreme_record()` is deprecated and replaced by `derive_extreme_event()` - - `derive_var_dthcaus()` and `dthcaus_source()` are deprecated and replaced by `derive_vars_extreme_event()` - - `derive_var_extreme_dt()` is deprecated and replaced by `derive_vars_extreme_event()` + - `derive_var_dthcaus()` is deprecated and replaced by `derive_vars_extreme_event()` + - `date_source()` is deprecated and replaced by `derive_vars_extreme_event()` + - `dthcaus_source()` is deprecated and replaced by `derive_vars_extreme_event()` + - `derive_var_extreme_dt()` and `derive_var_extreme_dtm` are deprecated and replaced by `derive_vars_extreme_event()` + - `get_summary_records()` is deprecated. Please use the `dataset_add` argument in `derive_summary_records()`. ### Phase 2 (warning) diff --git a/R/derive_var_extreme_date.R b/R/derive_var_extreme_date.R index c6c32a2bc2..82c4d6afbe 100644 --- a/R/derive_var_extreme_date.R +++ b/R/derive_var_extreme_date.R @@ -234,7 +234,6 @@ derive_var_extreme_dtm <- function(dataset, source_datasets, mode, subject_keys = get_admiral_option("subject_keys")) { - deprecate_inform( when = "1.2.0", what = "derive_var_extreme_dtm()", @@ -567,7 +566,6 @@ derive_var_extreme_dt <- function(dataset, source_datasets, mode, subject_keys = get_admiral_option("subject_keys")) { - deprecate_inform( when = "1.2.0", what = "derive_var_extreme_dt()", diff --git a/R/get_summary_records.R b/R/get_summary_records.R index 2d09e633a9..c18787b2fd 100644 --- a/R/get_summary_records.R +++ b/R/get_summary_records.R @@ -148,6 +148,16 @@ get_summary_records <- function(dataset, by_vars, filter = NULL, set_values_to = NULL) { + deprecate_inform( + when = "1.2.0", + what = "get_summary_records()", + with = "derive_summary_records()", + details = c( + x = "This message will turn into a warning with release of 1.3.0", + i = "https://pharmaverse.github.io/admiral/reference/derive_summary_records.html" + ) + ) + assert_vars(by_vars) filter <- assert_filter_cond(enexpr(filter), optional = TRUE) assert_data_frame( diff --git a/tests/testthat/_snaps/get_summary_records.md b/tests/testthat/_snaps/get_summary_records.md new file mode 100644 index 0000000000..3c420e7454 --- /dev/null +++ b/tests/testthat/_snaps/get_summary_records.md @@ -0,0 +1,12 @@ +# get_summary_records Test 1: Summarize average of triplicate ECG interval values + + Code + df <- input %>% get_summary_records(by_vars = exprs(USUBJID, PARAM, AVISIT), + set_values_to = exprs(AVAL = mean(AVAL, na.rm = TRUE), DTYPE = "AVERAGE")) %>% + dplyr::mutate(AVAL = round(AVAL)) + Message + `get_summary_records()` was deprecated in admiral 1.2.0. + i Please use `derive_summary_records()` instead. + x This message will turn into a warning with release of 1.3.0 + i https://pharmaverse.github.io/admiral/reference/derive_summary_records.html + diff --git a/tests/testthat/test-derive_var_extreme_date.R b/tests/testthat/test-derive_var_extreme_date.R index 7256dcc75c..89241412e1 100644 --- a/tests/testthat/test-derive_var_extreme_date.R +++ b/tests/testthat/test-derive_var_extreme_date.R @@ -25,7 +25,6 @@ ae <- tibble::tribble( # derive_var_extreme_dt ---- ## Test 1: Message sent to users ---- test_that("derive_var_extreme_dt Test 1: Message sent to users", { - ae_start <- date_source( dataset_name = "ae", date = AESTDTM @@ -54,8 +53,8 @@ test_that("derive_var_extreme_dt Test 1: Message sent to users", { source_datasets = list(ae = ae, adsl = adsl), ae_start, ae_end, adsl_trtdate, adsl_dthdate, mode = "last" + ) ) -) }) # derive_var_extreme_dt ---- @@ -168,7 +167,6 @@ test_that("derive_var_extreme_dt Test 4: `NA` dates are excluded", { # derive_var_extreme_dtm ---- ## Test 5: Message sent to users ---- test_that("derive_var_extreme_dtm Test 5: Message sent to users", { - ae_start <- date_source( dataset_name = "ae", date = convert_dtc_to_dtm(AESTDTC), @@ -210,16 +208,15 @@ test_that("derive_var_extreme_dtm Test 5: Message sent to users", { ) ) -expect_snapshot( - derive_var_extreme_dtm( - adsl, - new_var = LSTALVDTM, - source_datasets = list(ae = ae, adsl = adsl), - ae_start, ae_end, adsl_trtdate, adsl_dthdate, - mode = "last" + expect_snapshot( + derive_var_extreme_dtm( + adsl, + new_var = LSTALVDTM, + source_datasets = list(ae = ae, adsl = adsl), + ae_start, ae_end, adsl_trtdate, adsl_dthdate, + mode = "last" + ) ) -) - }) # derive_var_extreme_dtm ---- diff --git a/tests/testthat/test-get_summary_records.R b/tests/testthat/test-get_summary_records.R index fa3fb5daf5..ef16585064 100644 --- a/tests/testthat/test-get_summary_records.R +++ b/tests/testthat/test-get_summary_records.R @@ -22,6 +22,46 @@ test_that("get_summary_records Test 1: Summarize average of triplicate ECG inter "XYZ-1002", 9, "QTcF Int. (msec)", "Visit 3", "2016-03-24T10:56", 402, "Active 20mg" ) + expect_snapshot( + df <- input %>% + get_summary_records( + by_vars = exprs(USUBJID, PARAM, AVISIT), + set_values_to = exprs( + AVAL = mean(AVAL, na.rm = TRUE), + DTYPE = "AVERAGE" + ) + ) %>% + dplyr::mutate(AVAL = round(AVAL)) + ) +}) + +## Test 1: Summarize the average of the triplicate ECG interval values (AVAL) ---- +test_that("get_summary_records Test 1: Summarize average of triplicate ECG interval values", { + # Suppress lifecycle messages within the test environment + withr::local_options(list(lifecycle_verbosity = "quiet")) + + input <- tibble::tribble( + ~USUBJID, ~EGSEQ, ~PARAM, ~AVISIT, ~EGDTC, ~AVAL, ~TRTA, + "XYZ-1001", 1, "QTcF Int. (msec)", "Baseline", "2016-02-24T07:50", 385, NA_character_, + "XYZ-1001", 2, "QTcF Int. (msec)", "Baseline", "2016-02-24T07:52", 399, NA_character_, + "XYZ-1001", 3, "QTcF Int. (msec)", "Baseline", "2016-02-24T07:56", 396, NA_character_, + "XYZ-1001", 4, "QTcF Int. (msec)", "Visit 2", "2016-03-08T09:45", 384, "Placebo", + "XYZ-1001", 5, "QTcF Int. (msec)", "Visit 2", "2016-03-08T09:48", 393, "Placebo", + "XYZ-1001", 6, "QTcF Int. (msec)", "Visit 2", "2016-03-08T09:51", 388, "Placebo", + "XYZ-1001", 7, "QTcF Int. (msec)", "Visit 3", "2016-03-22T10:45", 385, "Placebo", + "XYZ-1001", 8, "QTcF Int. (msec)", "Visit 3", "2016-03-22T10:48", 394, "Placebo", + "XYZ-1001", 9, "QTcF Int. (msec)", "Visit 3", "2016-03-22T10:51", 402, "Placebo", + "XYZ-1002", 1, "QTcF Int. (msec)", "Baseline", "2016-02-22T07:58", 399, NA_character_, + "XYZ-1002", 2, "QTcF Int. (msec)", "Baseline", "2016-02-22T07:58", 410, NA_character_, + "XYZ-1002", 3, "QTcF Int. (msec)", "Baseline", "2016-02-22T08:01", 392, NA_character_, + "XYZ-1002", 4, "QTcF Int. (msec)", "Visit 2", "2016-03-06T09:50", 401, "Active 20mg", + "XYZ-1002", 5, "QTcF Int. (msec)", "Visit 2", "2016-03-06T09:53", 407, "Active 20mg", + "XYZ-1002", 6, "QTcF Int. (msec)", "Visit 2", "2016-03-06T09:56", 400, "Active 20mg", + "XYZ-1002", 7, "QTcF Int. (msec)", "Visit 3", "2016-03-24T10:50", 412, "Active 20mg", + "XYZ-1002", 8, "QTcF Int. (msec)", "Visit 3", "2016-03-24T10:53", 414, "Active 20mg", + "XYZ-1002", 9, "QTcF Int. (msec)", "Visit 3", "2016-03-24T10:56", 402, "Active 20mg" + ) + actual_output <- input %>% get_summary_records( by_vars = exprs(USUBJID, PARAM, AVISIT), @@ -51,6 +91,9 @@ test_that("get_summary_records Test 1: Summarize average of triplicate ECG inter ## Test 2: Derive more than one summary variable ---- test_that("get_summary_records Test 2: Derive more than one summary variable", { + # Suppress lifecycle messages within the test environment + withr::local_options(list(lifecycle_verbosity = "quiet")) + input <- tibble::tribble( ~USUBJID, ~EGSEQ, ~PARAM, ~AVISIT, ~EGDTC, ~AVAL, ~TRTA, "XYZ-1001", 1, "QTcF Int. (msec)", "Baseline", "2016-02-24T07:50", 385, NA_character_, @@ -110,6 +153,9 @@ test_that("get_summary_records Test 2: Derive more than one summary variable", { ## Test 3: Compute avg AVAL only if >2 records within by group ---- test_that("get_summary_records Test 3: Compute avg AVAL only if >2 records within by group", { + # Suppress lifecycle messages within the test environment + withr::local_options(list(lifecycle_verbosity = "quiet")) + input <- tibble::tribble( ~USUBJID, ~EGSEQ, ~PARAM, ~AVISIT, ~EGDTC, ~AVAL, ~TRTA, "XYZ-1001", 1, "QTcF Int. (msec)", "Baseline", "2016-02-24T07:50", 385, NA_character_,