From c389dd9b4ffd76088a461245697a0e7109caf804 Mon Sep 17 00:00:00 2001 From: ProfessorP Date: Wed, 30 Oct 2024 01:10:20 -0400 Subject: [PATCH] Aligned tables and changed the STUDYID, USUBJID to get_admiral_option("subject_keys") for the bds_exposure vignette --- NEWS.md | 10 ++++--- .../test-create_single_dose_dataset.R | 30 +++++++++---------- vignettes/bds_exposure.Rmd | 6 ++-- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8313f5c25..6b771a130 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,10 +10,8 @@ - Replace use of `data("sdtm")` with `sdtm <- pharmaverse::sdtm` in templates and vignettes. (#2498) ## Updates of Existing Functions -- `derive_vars_atc()` and `create_single_dose_dataset()` `by_vars` argument updated to use `get_admiral_option("subject_keys")` instead of `USUBJID` or `STUDYID`. -- test scripts, R, and markdown files for `create_single_dose_dataset` and `occds.Rmd` updated to include a `STUDYID` column because of `get_admiral_option("subject_keys")` update above. -- `derive_extreme_event()` was fixed such that `check_type = "none"` is accepted -again. (#2462) + + ## Breaking Changes @@ -50,6 +48,8 @@ again. (#2462) # admiral 1.1.1 - `derive_locf_records()` documentation example was fixed to display LOCF records. (#2461) +- `derive_vars_atc()` and `create_single_dose_dataset()` `by_vars` argument updated to use `get_admiral_option("subject_keys")` instead of `USUBJID` or `STUDYID` in `bds_exposure.Rmd`. +- test scripts, R, and markdown files for `create_single_dose_dataset` and `occds.Rmd` updated to include a `STUDYID` column because of `get_admiral_option("subject_keys")` update above. # admiral 1.1.0 @@ -61,6 +61,8 @@ again. (#2462) - New `country_code_lookup()` metadata added to decode countries based on [ISO 3166 codes](https://www.iso.org/iso-3166-country-codes.html). (#2388) ## Updates of Existing Functions +- `derive_extreme_event()` was fixed such that `check_type = "none"` is accepted +again. (#2462) - `group_var` (optional) parameter is added to `derive_var_trtemfl()` to derive `TRTEMFL` for AE data if the data are collected as one episode of AE with multiple lines. (#2302) diff --git a/tests/testthat/test-create_single_dose_dataset.R b/tests/testthat/test-create_single_dose_dataset.R index bee80ef41..bf84ffde0 100644 --- a/tests/testthat/test-create_single_dose_dataset.R +++ b/tests/testthat/test-create_single_dose_dataset.R @@ -2,24 +2,24 @@ ## Test 1: Works as expected for Q*/EVERY * cases ---- test_that("create_single_dose_dataset Test 1: Works as expected for Q*/EVERY * cases", { input <- tibble::tribble( - ~STUDYID, ~USUBJID, ~EXDOSFRQ, ~ASTDT, ~AENDT, - "STUDY01", "P01", "Q2D", ymd("2021-01-01"), ymd("2021-01-07"), - "STUDY01", "P01", "Q3D", ymd("2021-01-08"), ymd("2021-01-14"), + ~STUDYID, ~USUBJID, ~EXDOSFRQ, ~ASTDT, ~AENDT, + "STUDY01", "P01", "Q2D", ymd("2021-01-01"), ymd("2021-01-07"), + "STUDY01", "P01", "Q3D", ymd("2021-01-08"), ymd("2021-01-14"), "STUDY01", "P01", "EVERY 2 WEEKS", ymd("2021-01-15"), ymd("2021-01-29"), - "STUDY01", "P02", "ONCE", ymd("2021-02-02"), ymd("2021-02-02") + "STUDY01", "P02", "ONCE", ymd("2021-02-02"), ymd("2021-02-02") ) expected_output <- tibble::tribble( - ~STUDYID, ~USUBJID, ~EXDOSFRQ, ~ASTDT, ~AENDT, - "STUDY01", "P01", "ONCE", ymd("2021-01-01"), ymd("2021-01-01"), - "STUDY01", "P01", "ONCE", ymd("2021-01-03"), ymd("2021-01-03"), - "STUDY01", "P01", "ONCE", ymd("2021-01-05"), ymd("2021-01-05"), - "STUDY01", "P01", "ONCE", ymd("2021-01-07"), ymd("2021-01-07"), - "STUDY01", "P01", "ONCE", ymd("2021-01-08"), ymd("2021-01-08"), - "STUDY01", "P01", "ONCE", ymd("2021-01-11"), ymd("2021-01-11"), - "STUDY01", "P01", "ONCE", ymd("2021-01-14"), ymd("2021-01-14"), - "STUDY01", "P01", "ONCE", ymd("2021-01-15"), ymd("2021-01-15"), - "STUDY01", "P01", "ONCE", ymd("2021-01-29"), ymd("2021-01-29"), - "STUDY01", "P02", "ONCE", ymd("2021-02-02"), ymd("2021-02-02") + ~STUDYID, ~USUBJID, ~EXDOSFRQ, ~ASTDT, ~AENDT, + "STUDY01", "P01", "ONCE", ymd("2021-01-01"), ymd("2021-01-01"), + "STUDY01", "P01", "ONCE", ymd("2021-01-03"), ymd("2021-01-03"), + "STUDY01", "P01", "ONCE", ymd("2021-01-05"), ymd("2021-01-05"), + "STUDY01", "P01", "ONCE", ymd("2021-01-07"), ymd("2021-01-07"), + "STUDY01", "P01", "ONCE", ymd("2021-01-08"), ymd("2021-01-08"), + "STUDY01", "P01", "ONCE", ymd("2021-01-11"), ymd("2021-01-11"), + "STUDY01", "P01", "ONCE", ymd("2021-01-14"), ymd("2021-01-14"), + "STUDY01", "P01", "ONCE", ymd("2021-01-15"), ymd("2021-01-15"), + "STUDY01", "P01", "ONCE", ymd("2021-01-29"), ymd("2021-01-29"), + "STUDY01", "P02", "ONCE", ymd("2021-02-02"), ymd("2021-02-02") ) expect_dfs_equal( diff --git a/vignettes/bds_exposure.Rmd b/vignettes/bds_exposure.Rmd index bbb86e599..212d9002b 100644 --- a/vignettes/bds_exposure.Rmd +++ b/vignettes/bds_exposure.Rmd @@ -81,7 +81,7 @@ adex <- derive_vars_merged( ex, dataset_add = adsl, new_vars = adsl_vars, - by_vars = exprs(STUDYID, USUBJID) + by_vars = get_admiral_option("subject_keys") ) ``` @@ -581,7 +581,7 @@ example call is: adex <- derive_var_obs_number( adex, new_var = ASEQ, - by_vars = exprs(STUDYID, USUBJID), + by_vars = get_admiral_option("subject_keys"), order = exprs(PARCAT1, ASTDT, VISIT, VISITNUM, EXSEQ, PARAMN), check_type = "error" ) @@ -602,7 +602,7 @@ If needed, the other `ADSL` variables can now be added: adex <- adex %>% derive_vars_merged( dataset_add = select(adsl, !!!negate_vars(adsl_vars)), - by_vars = exprs(STUDYID, USUBJID) + by_vars = get_admiral_option("subject_keys") ) ``` ## Add Labels and Attributes {#attributes}