From 0335c66529bf35d49568434d8a66e8cf2c2aa21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:52:11 +0000 Subject: [PATCH] feat: remove datanames from shinyttests2 --- tests/testthat/test-shinytest2-tm_a_gee.R | 4 +-- tests/testthat/test-shinytest2-tm_a_mmrm.R | 7 ++--- .../test-shinytest2-tm_g_barchart_simple.R | 5 +--- tests/testthat/test-shinytest2-tm_g_ci.R | 4 +-- .../test-shinytest2-tm_g_forest_rsp.R | 24 +++++++--------- .../test-shinytest2-tm_g_forest_tte.R | 7 ++--- tests/testthat/test-shinytest2-tm_g_ipp.R | 28 ++++++++----------- tests/testthat/test-shinytest2-tm_g_km.R | 24 +++++++--------- .../testthat/test-shinytest2-tm_g_lineplot.R | 5 +--- .../test-shinytest2-tm_g_pp_adverse_events.R | 9 ++---- ...test-shinytest2-tm_g_pp_patient_timeline.R | 7 ++--- .../test-shinytest2-tm_g_pp_therapy.R | 8 ++---- .../testthat/test-shinytest2-tm_g_pp_vitals.R | 14 ++++------ .../test-shinytest2-tm_t_abnormality.R | 4 +-- ...inytest2-tm_t_abnormality_by_worst_grade.R | 20 ++++++------- tests/testthat/test-shinytest2-tm_t_ancova.R | 14 ++++------ .../test-shinytest2-tm_t_binary_outcome.R | 26 ++++++++--------- tests/testthat/test-shinytest2-tm_t_coxreg.R | 4 +-- tests/testthat/test-shinytest2-tm_t_events.R | 4 +-- .../test-shinytest2-tm_t_events_by_grade.R | 11 +++----- .../test-shinytest2-tm_t_events_patyear.R | 5 +--- .../test-shinytest2-tm_t_events_summary.R | 21 ++++++-------- .../testthat/test-shinytest2-tm_t_exposure.R | 9 ++---- .../testthat/test-shinytest2-tm_t_logistic.R | 5 +--- .../test-shinytest2-tm_t_mult_events.R | 5 +--- .../test-shinytest2-tm_t_pp_basic_info.R | 3 +- .../test-shinytest2-tm_t_pp_laboratory.R | 5 +--- .../test-shinytest2-tm_t_pp_medical_history.R | 7 ++--- ...test-shinytest2-tm_t_pp_prior_medication.R | 7 ++--- .../test-shinytest2-tm_t_shift_by_arm.R | 5 +--- ...st-shinytest2-tm_t_shift_by_arm_by_worst.R | 7 ++--- .../test-shinytest2-tm_t_shift_by_grade.R | 5 +--- tests/testthat/test-shinytest2-tm_t_smq.R | 25 ++++++++--------- tests/testthat/test-shinytest2-tm_t_summary.R | 12 ++++---- .../test-shinytest2-tm_t_summary_by.R | 5 +--- tests/testthat/test-shinytest2-tm_t_tte.R | 5 +--- 36 files changed, 130 insertions(+), 230 deletions(-) diff --git a/tests/testthat/test-shinytest2-tm_a_gee.R b/tests/testthat/test-shinytest2-tm_a_gee.R index c83da2095..1edaeb45d 100644 --- a/tests/testthat/test-shinytest2-tm_a_gee.R +++ b/tests/testthat/test-shinytest2-tm_a_gee.R @@ -15,9 +15,7 @@ app_driver_tm_a_gee <- function() { ) %>% droplevels() }) - datanames <- c("ADSL", "ADQS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_a_mmrm.R b/tests/testthat/test-shinytest2-tm_a_mmrm.R index da06e4078..4c98bd0bc 100644 --- a/tests/testthat/test-shinytest2-tm_a_mmrm.R +++ b/tests/testthat/test-shinytest2-tm_a_mmrm.R @@ -1,4 +1,4 @@ -app_driver_tm_a_mmrm <- function(fit_model = TRUE) { # nolint: object_length. +app_driver_tm_a_mmrm <- function(fit_model = TRUE) { arm_ref_comp <- list( ARMCD = list( ref = "ARM B", @@ -20,10 +20,7 @@ app_driver_tm_a_mmrm <- function(fit_model = TRUE) { # nolint: object_length. as.factor() #' making consecutive numeric factor ) }) - - datanames <- c("ADSL", "ADQS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_var <- choices_selected(c("ARM", "ARMCD"), "ARM") diff --git a/tests/testthat/test-shinytest2-tm_g_barchart_simple.R b/tests/testthat/test-shinytest2-tm_g_barchart_simple.R index 1d730f22d..467a596bb 100644 --- a/tests/testthat/test-shinytest2-tm_g_barchart_simple.R +++ b/tests/testthat/test-shinytest2-tm_g_barchart_simple.R @@ -10,10 +10,7 @@ app_driver_tm_g_barchart_simple <- function() { # nolint: object_length. !((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")) ) }) - - datanames <- c("ADSL", "ADAE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_g_ci.R b/tests/testthat/test-shinytest2-tm_g_ci.R index 687328b77..9e0719f52 100644 --- a/tests/testthat/test-shinytest2-tm_g_ci.R +++ b/tests/testthat/test-shinytest2-tm_g_ci.R @@ -4,8 +4,8 @@ app_driver_tm_g_ci <- function() { ADSL <- teal.data::rADSL ADLB <- teal.data::rADLB }) - teal.data::datanames(data) <- c("ADSL", "ADLB") - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[c("ADSL", "ADLB")] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] + init_teal_app_driver( data = data, modules = tm_g_ci( diff --git a/tests/testthat/test-shinytest2-tm_g_forest_rsp.R b/tests/testthat/test-shinytest2-tm_g_forest_rsp.R index d846648f4..d73e1237e 100644 --- a/tests/testthat/test-shinytest2-tm_g_forest_rsp.R +++ b/tests/testthat/test-shinytest2-tm_g_forest_rsp.R @@ -1,18 +1,14 @@ app_driver_tm_g_forest_rsp <- function() { - data <- teal.data::teal_data() %>% - within({ - library(dplyr) - library(tern) - ADSL <- teal.data::rADSL - ADRS <- teal.data::rADRS %>% - mutate(AVALC = d_onco_rsp_label(AVALC)) %>% - with_label("Character Result/Finding") %>% - filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") - }) - - datanames <- c("ADSL", "ADRS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + data <- within(teal.data::teal_data(), { + library(dplyr) + library(tern) + ADSL <- teal.data::rADSL + ADRS <- teal.data::rADRS %>% + mutate(AVALC = d_onco_rsp_label(AVALC)) %>% + with_label("Character Result/Finding") %>% + filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ARM = list( diff --git a/tests/testthat/test-shinytest2-tm_g_forest_tte.R b/tests/testthat/test-shinytest2-tm_g_forest_tte.R index a47d0a93c..20194dfc4 100644 --- a/tests/testthat/test-shinytest2-tm_g_forest_tte.R +++ b/tests/testthat/test-shinytest2-tm_g_forest_tte.R @@ -1,13 +1,10 @@ -app_driver_tm_g_forest_tte <- function() { # nolint: object_length. +app_driver_tm_g_forest_tte <- function() { data <- within(teal.data::teal_data(), { ADSL <- teal.modules.clinical::tmc_ex_adsl ADSL$RACE <- with_label(droplevels(ADSL$RACE), "Race") ADTTE <- teal.modules.clinical::tmc_ex_adtte }) - - datanames <- c("ADSL", "ADTTE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ARM = list( diff --git a/tests/testthat/test-shinytest2-tm_g_ipp.R b/tests/testthat/test-shinytest2-tm_g_ipp.R index a7b6f9f7d..dd3fda135 100644 --- a/tests/testthat/test-shinytest2-tm_g_ipp.R +++ b/tests/testthat/test-shinytest2-tm_g_ipp.R @@ -1,20 +1,16 @@ app_driver_tm_g_ipp <- function() { - data <- teal.data::teal_data() %>% - within({ - library(dplyr) - library(tern) - ADSL <- teal.data::rADSL %>% - slice(1:20) %>% - df_explicit_na() - ADLB <- teal.data::rADLB %>% - filter(USUBJID %in% ADSL$USUBJID) %>% - df_explicit_na() %>% - filter(AVISIT != "SCREENING") - }) - - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + data <- within(teal.data::teal_data(), { + library(dplyr) + library(tern) + ADSL <- teal.data::rADSL %>% + slice(1:20) %>% + df_explicit_na() + ADLB <- teal.data::rADLB %>% + filter(USUBJID %in% ADSL$USUBJID) %>% + df_explicit_na() %>% + filter(AVISIT != "SCREENING") + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_g_km.R b/tests/testthat/test-shinytest2-tm_g_km.R index 7eede042a..a6a7d0e4e 100644 --- a/tests/testthat/test-shinytest2-tm_g_km.R +++ b/tests/testthat/test-shinytest2-tm_g_km.R @@ -1,18 +1,14 @@ app_driver_tm_g_km <- function() { - data <- teal.data::teal_data() %>% - within({ - library(dplyr) - ADSL <- tmc_ex_adsl - ADTTE <- tmc_ex_adtte %>% - rename( - VALUE_UNIT = AVALU, - ANALYSIS_VAL = AVAL, - CENSORING = CNSR - ) - }) - - datanames <- c("ADSL", "ADTTE") - teal.data::datanames(data) <- datanames + data <- within(teal.data::teal_data(), { + library(dplyr) + ADSL <- tmc_ex_adsl + ADTTE <- tmc_ex_adtte %>% + rename( + VALUE_UNIT = AVALU, + ANALYSIS_VAL = AVAL, + CENSORING = CNSR + ) + }) teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] arm_ref_comp <- list( diff --git a/tests/testthat/test-shinytest2-tm_g_lineplot.R b/tests/testthat/test-shinytest2-tm_g_lineplot.R index caa70036d..35dfe47c7 100644 --- a/tests/testthat/test-shinytest2-tm_g_lineplot.R +++ b/tests/testthat/test-shinytest2-tm_g_lineplot.R @@ -8,10 +8,7 @@ app_driver_tm_g_lineplot <- function() { AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min) ) }) - - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R b/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R index 1398afa0f..562a85286 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R @@ -1,15 +1,12 @@ -app_driver_tm_g_pp_adverse_events <- function() { # nolint: object_length - data <- teal.data::teal_data() |> within({ +app_driver_tm_g_pp_adverse_events <- function() { # nolint: object_length. + data <- within(teal.data::teal_data(), { library(nestcolor) library(dplyr) ADAE <- teal.data::rADAE ADSL <- teal.data::rADSL %>% filter(USUBJID %in% ADAE$USUBJID) }) - - teal.data::datanames(data) <- c("ADAE", "ADSL") - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[c("ADAE", "ADSL")] - + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R b/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R index 8bbcccf63..ce0f83ed1 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R @@ -1,4 +1,4 @@ -app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length +app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length. data <- teal.data::teal_data() data <- within(data, { library(dplyr) @@ -21,12 +21,11 @@ app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length }) adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") - teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM") - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[c("ADSL", "ADAE", "ADCM")] + + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] teal.data::join_keys(data)["ADCM", "ADCM"] <- adcm_keys teal.data::join_keys(data)["ADAE", "ADCM"] <- c("STUDYID", "USUBJID") - init_teal_app_driver( data = data, modules = tm_g_pp_patient_timeline( diff --git a/tests/testthat/test-shinytest2-tm_g_pp_therapy.R b/tests/testthat/test-shinytest2-tm_g_pp_therapy.R index 3f40a0220..b6d798a1c 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_therapy.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_therapy.R @@ -1,4 +1,4 @@ -app_driver_tm_g_pp_therapy <- function() { # nolint: object_length. +app_driver_tm_g_pp_therapy <- function() { data <- within(teal.data::teal_data(), { ADCM <- teal.modules.clinical::tmc_ex_adcm ADSL <- dplyr::filter( @@ -23,10 +23,8 @@ app_driver_tm_g_pp_therapy <- function() { # nolint: object_length. }) adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") - datanames <- c("ADSL", "ADCM") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] teal.data::join_keys(data)["ADCM", "ADCM"] <- adcm_keys init_teal_app_driver( @@ -144,7 +142,7 @@ testthat::test_that( # Test changing selection ------------------------------------ # Check if a new selection of input changes the plot and table without any validation errors. -test_different_selection <- function(input_name, input_id, new_value) { # nolint object_length +test_different_selection <- function(input_name, input_id, new_value) { testthat::test_that( sprintf( "e2e - tm_g_pp_therapy: Selection of %s changes the plot and table without any validation errors.", diff --git a/tests/testthat/test-shinytest2-tm_g_pp_vitals.R b/tests/testthat/test-shinytest2-tm_g_pp_vitals.R index c8fe28944..533e9b6dc 100644 --- a/tests/testthat/test-shinytest2-tm_g_pp_vitals.R +++ b/tests/testthat/test-shinytest2-tm_g_pp_vitals.R @@ -1,13 +1,9 @@ app_driver_tm_g_pp_vitals <- function() { - data <- teal.data::teal_data() %>% - within({ - ADSL <- teal.data::rADSL - ADVS <- teal.data::rADVS - }) - - datanames <- c("ADSL", "ADVS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + data <- within(teal.data::teal_data(), { + ADSL <- teal.data::rADSL + ADVS <- teal.data::rADVS + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_abnormality.R b/tests/testthat/test-shinytest2-tm_t_abnormality.R index af84708b9..27ada1f1e 100644 --- a/tests/testthat/test-shinytest2-tm_t_abnormality.R +++ b/tests/testthat/test-shinytest2-tm_t_abnormality.R @@ -12,9 +12,7 @@ app_driver_tm_t_abnormality <- function() { ) %>% with_label("On Treatment Record Flag") ) }) - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R b/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R index c33cf8c12..ec7224ba7 100644 --- a/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R +++ b/tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R @@ -1,16 +1,12 @@ -app_driver_tm_t_abnormality_by_worst_grade <- function() { # nolint: object_length - data <- teal.data::teal_data() %>% - within({ - library(dplyr) +app_driver_tm_t_abnormality_by_worst_grade <- function() { # nolint: object_length. + data <- within(teal.data::teal_data(), { + library(dplyr) - ADSL <- teal.data::rADSL - ADLB <- teal.data::rADLB %>% - filter(!AVISIT %in% c("SCREENING", "BASELINE")) - }) - - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + ADSL <- teal.data::rADSL + ADLB <- teal.data::rADLB %>% + filter(!AVISIT %in% c("SCREENING", "BASELINE")) + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_ancova.R b/tests/testthat/test-shinytest2-tm_t_ancova.R index 0e2ad9400..c2b6bf63c 100644 --- a/tests/testthat/test-shinytest2-tm_t_ancova.R +++ b/tests/testthat/test-shinytest2-tm_t_ancova.R @@ -1,13 +1,9 @@ app_driver_tm_t_ancova <- function() { - data <- teal.data::teal_data() %>% - within({ - ADSL <- tmc_ex_adsl - ADQS <- tmc_ex_adqs - }) - - datanames <- c("ADSL", "ADQS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + data <- within(teal.data::teal_data(), { + ADSL <- tmc_ex_adsl + ADQS <- tmc_ex_adqs + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ARM = list( diff --git a/tests/testthat/test-shinytest2-tm_t_binary_outcome.R b/tests/testthat/test-shinytest2-tm_t_binary_outcome.R index 85bfb0e40..368d8a7fa 100644 --- a/tests/testthat/test-shinytest2-tm_t_binary_outcome.R +++ b/tests/testthat/test-shinytest2-tm_t_binary_outcome.R @@ -1,19 +1,15 @@ app_driver_tm_t_binary_outcome <- function() { - data <- teal.data::teal_data() %>% - within({ - library(dplyr) - ADSL <- teal.data::rADSL - ADRS <- teal.data::rADRS %>% - mutate( - AVALC = d_onco_rsp_label(AVALC) %>% - with_label("Character Result/Finding") - ) %>% - filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") - }) - - datanames <- c("ADSL", "ADRS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + data <- within(teal.data::teal_data(), { + library(dplyr) + ADSL <- teal.data::rADSL + ADRS <- teal.data::rADRS %>% + mutate( + AVALC = d_onco_rsp_label(AVALC) %>% + with_label("Character Result/Finding") + ) %>% + filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ARMCD = list(ref = "ARM B", comp = c("ARM A", "ARM C")), diff --git a/tests/testthat/test-shinytest2-tm_t_coxreg.R b/tests/testthat/test-shinytest2-tm_t_coxreg.R index 7e6d94b22..b3d18eef3 100644 --- a/tests/testthat/test-shinytest2-tm_t_coxreg.R +++ b/tests/testthat/test-shinytest2-tm_t_coxreg.R @@ -5,9 +5,7 @@ app_driver_tm_t_coxreg <- function() { ADSL <- teal.data::rADSL ADTTE <- teal.data::rADTTE }) - datanames <- c("ADSL", "ADTTE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ACTARMCD = list( diff --git a/tests/testthat/test-shinytest2-tm_t_events.R b/tests/testthat/test-shinytest2-tm_t_events.R index a951ec560..14574d763 100644 --- a/tests/testthat/test-shinytest2-tm_t_events.R +++ b/tests/testthat/test-shinytest2-tm_t_events.R @@ -4,9 +4,7 @@ app_driver_tm_t_events <- function() { ADSL <- teal.data::rADSL ADAE <- teal.data::rADAE }) - datanames <- c("ADSL", "ADAE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_events_by_grade.R b/tests/testthat/test-shinytest2-tm_t_events_by_grade.R index 61cbf322f..11966c769 100644 --- a/tests/testthat/test-shinytest2-tm_t_events_by_grade.R +++ b/tests/testthat/test-shinytest2-tm_t_events_by_grade.R @@ -1,18 +1,15 @@ -app_driver_tm_t_events_by_grade <- function() { # nolint: object_length +app_driver_tm_t_events_by_grade <- function() { # nolint: object_length. data <- teal.data::teal_data() data <- within(data, { library(dplyr) ADSL <- teal.data::rADSL - lbls_adae <- col_labels(teal.data::rADAE) + .lbls_adae <- col_labels(teal.data::rADAE) ADAE <- teal.data::rADAE %>% mutate_if(is.character, as.factor) - col_labels(ADAE) <- lbls_adae + col_labels(ADAE) <- .lbls_adae }) - - datanames <- c("ADSL", "ADAE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_events_patyear.R b/tests/testthat/test-shinytest2-tm_t_events_patyear.R index 9e7474cc0..2f04d3894 100644 --- a/tests/testthat/test-shinytest2-tm_t_events_patyear.R +++ b/tests/testthat/test-shinytest2-tm_t_events_patyear.R @@ -8,10 +8,7 @@ app_driver_tm_t_events_patyear <- function() { mutate(is_event = CNSR == 0) %>% mutate(n_events = as.integer(is_event)) }) - - datanames <- c("ADSL", "ADAETTE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_events_summary.R b/tests/testthat/test-shinytest2-tm_t_events_summary.R index fada0378b..582be23ff 100644 --- a/tests/testthat/test-shinytest2-tm_t_events_summary.R +++ b/tests/testthat/test-shinytest2-tm_t_events_summary.R @@ -11,7 +11,7 @@ app_driver_tm_t_events_summary <- function() { ) ADAE <- teal.data::rADAE - add_event_flags <- function(dat) { + .add_event_flags <- function(dat) { dat <- dat %>% dplyr::mutate( TMPFL_SER = AESER == "Y", @@ -33,15 +33,12 @@ app_driver_tm_t_events_summary <- function() { dat } - ADAE <- ADAE %>% add_event_flags() + ADAE <- ADAE %>% .add_event_flags() - ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")] - aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")] + .ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")] + .aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")] }) - - datanames <- c("ADSL", "ADAE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, @@ -54,14 +51,14 @@ app_driver_tm_t_events_summary <- function() { selected = "ARM" ), flag_var_anl = teal.transform::choices_selected( - choices = teal.transform::variable_choices("ADAE", data[["ae_anl_vars"]]), - selected = data[["ae_anl_vars"]][1], + choices = teal.transform::variable_choices("ADAE", data[[".ae_anl_vars"]]), + selected = data[[".ae_anl_vars"]][1], keep_order = TRUE, fixed = FALSE ), flag_var_aesi = teal.transform::choices_selected( - choices = teal.transform::variable_choices("ADAE", data[["aesi_vars"]]), - selected = data[["aesi_vars"]][1], + choices = teal.transform::variable_choices("ADAE", data[[".aesi_vars"]]), + selected = data[[".aesi_vars"]][1], keep_order = TRUE, fixed = FALSE ), diff --git a/tests/testthat/test-shinytest2-tm_t_exposure.R b/tests/testthat/test-shinytest2-tm_t_exposure.R index b3c324301..9d26429fb 100644 --- a/tests/testthat/test-shinytest2-tm_t_exposure.R +++ b/tests/testthat/test-shinytest2-tm_t_exposure.R @@ -6,7 +6,7 @@ app_driver_tm_t_exposure <- function() { ADEX <- teal.data::rADEX set.seed(1, kind = "Mersenne-Twister") - labels <- col_labels(ADEX, fill = FALSE) + .labels <- col_labels(ADEX, fill = FALSE) ADEX <- ADEX %>% distinct(USUBJID, .keep_all = TRUE) %>% mutate( @@ -16,12 +16,9 @@ app_driver_tm_t_exposure <- function() { AVALU = "Days" ) %>% bind_rows(ADEX) - col_labels(ADEX) <- labels + col_labels(ADEX) <- .labels }) - - datanames <- c("ADSL", "ADEX") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_logistic.R b/tests/testthat/test-shinytest2-tm_t_logistic.R index d31d4ceda..695711fc3 100644 --- a/tests/testthat/test-shinytest2-tm_t_logistic.R +++ b/tests/testthat/test-shinytest2-tm_t_logistic.R @@ -6,10 +6,7 @@ app_driver_tm_t_logistic <- function() { ADRS <- teal.data::rADRS %>% filter(PARAMCD %in% c("BESRSPI", "INVET")) }) - - datanames <- c("ADSL", "ADRS") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ACTARMCD = list( diff --git a/tests/testthat/test-shinytest2-tm_t_mult_events.R b/tests/testthat/test-shinytest2-tm_t_mult_events.R index 7c5dfac91..965cb2408 100644 --- a/tests/testthat/test-shinytest2-tm_t_mult_events.R +++ b/tests/testthat/test-shinytest2-tm_t_mult_events.R @@ -4,10 +4,7 @@ app_driver_tm_t_mult_events <- function() { ADSL <- teal.data::rADSL ADCM <- teal.data::rADCM }) - - datanames <- c("ADSL", "ADCM") - teal.data::datanames(data) <- datanames - keys <- teal.data::default_cdisc_join_keys[datanames] + keys <- teal.data::default_cdisc_join_keys[names(data)] keys["ADCM", "ADCM"] <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") teal.data::join_keys(data) <- keys diff --git a/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R b/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R index 7ce990751..7244b0df2 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_basic_info.R @@ -3,8 +3,7 @@ app_driver_tm_t_pp_basic_info <- function() { data <- within(data, { ADSL <- teal.data::rADSL }) - teal.data::datanames(data) <- "ADSL" - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys["ADSL"] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R b/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R index 7b447023e..8a34ee727 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_laboratory.R @@ -4,10 +4,7 @@ app_driver_tm_t_pp_laboratory <- function() { ADSL <- teal.data::rADSL ADLB <- teal.data::rADLB }) - - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R b/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R index 4fae276b9..6f19fea85 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_medical_history.R @@ -1,12 +1,11 @@ -app_driver_tm_t_pp_medical_history <- function() { # nolint: object_length +app_driver_tm_t_pp_medical_history <- function() { # nolint: object_length. data <- teal.data::teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADMH <- tmc_ex_admh }) - datanames <- c("ADSL", "ADMH") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] + init_teal_app_driver( data = data, modules = tm_t_pp_medical_history( diff --git a/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R b/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R index 69eb2f545..428e1d485 100644 --- a/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R +++ b/tests/testthat/test-shinytest2-tm_t_pp_prior_medication.R @@ -1,4 +1,4 @@ -app_driver_tm_t_pp_prior_medication <- function() { # nolint: object_length +app_driver_tm_t_pp_prior_medication <- function() { # nolint: object_length. data <- teal.data::teal_data() data <- within(data, { library(dplyr) @@ -8,10 +8,7 @@ app_driver_tm_t_pp_prior_medication <- function() { # nolint: object_length ADCM$CMASTDTM <- ADCM$ASTDTM ADCM$CMAENDTM <- ADCM$AENDTM }) - - datanames <- c("ADSL", "ADCM") - teal.data::datanames(data) <- datanames - keys <- teal.data::default_cdisc_join_keys[datanames] + keys <- teal.data::default_cdisc_join_keys[names(data)] keys["ADCM", "ADCM"] <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") teal.data::join_keys(data) <- keys diff --git a/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R b/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R index 0ce89dc27..6a4ff0f64 100644 --- a/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R +++ b/tests/testthat/test-shinytest2-tm_t_shift_by_arm.R @@ -4,10 +4,7 @@ app_driver_tm_t_shift_by_arm <- function() { ADSL <- tmc_ex_adsl ADEG <- tmc_ex_adeg }) - - datanames <- c("ADSL", "ADEG") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R b/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R index a18e6fe2a..e7176d506 100644 --- a/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R +++ b/tests/testthat/test-shinytest2-tm_t_shift_by_arm_by_worst.R @@ -1,13 +1,10 @@ -app_driver_tm_t_shift_by_arm_by_worst <- function() { # nolint: object_length +app_driver_tm_t_shift_by_arm_by_worst <- function() { # nolint: object_length. data <- teal.data::teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADEG <- tmc_ex_adeg }) - - datanames <- c("ADSL", "ADEG") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R b/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R index d8f63809b..fbacdbb67 100644 --- a/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R +++ b/tests/testthat/test-shinytest2-tm_t_shift_by_grade.R @@ -4,10 +4,7 @@ app_driver_tm_t_shift_by_grade <- function() { ADSL <- teal.data::rADSL ADLB <- teal.data::rADLB }) - - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_smq.R b/tests/testthat/test-shinytest2-tm_t_smq.R index 5f2585410..8789e2491 100644 --- a/tests/testthat/test-shinytest2-tm_t_smq.R +++ b/tests/testthat/test-shinytest2-tm_t_smq.R @@ -4,24 +4,21 @@ app_driver_tm_t_smq <- function() { ADSL <- teal.data::rADSL ADAE <- teal.data::rADAE - names_baskets <- grep("^(SMQ|CQ).*NAM$", names(ADAE), value = TRUE) - names_scopes <- grep("^SMQ.*SC$", names(ADAE), value = TRUE) + .names_baskets <- grep("^(SMQ|CQ).*NAM$", names(ADAE), value = TRUE) + .names_scopes <- grep("^SMQ.*SC$", names(ADAE), value = TRUE) - cs_baskets <- choices_selected( - choices = teal.transform::variable_choices(ADAE, subset = names_baskets), - selected = names_baskets + .cs_baskets <- choices_selected( + choices = teal.transform::variable_choices(ADAE, subset = .names_baskets), + selected = .names_baskets ) - cs_scopes <- choices_selected( - choices = teal.transform::variable_choices(ADAE, subset = names_scopes), - selected = names_scopes, + .cs_scopes <- choices_selected( + choices = teal.transform::variable_choices(ADAE, subset = .names_scopes), + selected = .names_scopes, fixed = TRUE ) }) - - datanames <- c("ADSL", "ADAE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, @@ -43,8 +40,8 @@ app_driver_tm_t_smq <- function() { drop_arm_levels = TRUE, na_level = default_na_str(), smq_varlabel = "Standardized MedDRA Query", - baskets = data[["cs_baskets"]], - scopes = data[["cs_scopes"]], + baskets = data[[".cs_baskets"]], + scopes = data[[".cs_scopes"]], llt = teal.transform::choices_selected( choices = teal.transform::variable_choices(data[["ADAE"]], subset = c("AEDECOD", "SEX")), selected = "AEDECOD" diff --git a/tests/testthat/test-shinytest2-tm_t_summary.R b/tests/testthat/test-shinytest2-tm_t_summary.R index 26598d556..1ae7a9b79 100644 --- a/tests/testthat/test-shinytest2-tm_t_summary.R +++ b/tests/testthat/test-shinytest2-tm_t_summary.R @@ -1,11 +1,9 @@ app_driver_tm_t_summary <- function() { - data <- teal.data::teal_data() %>% - within({ - ADSL <- teal.data::rADSL - ADSL$EOSDY[1] <- NA_integer_ - }) - teal.data::datanames(data) <- "ADSL" - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys["ADSL"] + data <- within(teal.data::teal_data(), { + ADSL <- teal.data::rADSL + ADSL$EOSDY[1] <- NA_integer_ + }) + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_summary_by.R b/tests/testthat/test-shinytest2-tm_t_summary_by.R index 44564d331..89496850c 100644 --- a/tests/testthat/test-shinytest2-tm_t_summary_by.R +++ b/tests/testthat/test-shinytest2-tm_t_summary_by.R @@ -4,10 +4,7 @@ app_driver_tm_t_summary_by <- function() { ADSL <- teal.data::rADSL ADLB <- teal.data::rADLB }) - - datanames <- c("ADSL", "ADLB") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] init_teal_app_driver( data = data, diff --git a/tests/testthat/test-shinytest2-tm_t_tte.R b/tests/testthat/test-shinytest2-tm_t_tte.R index 59cfc7aad..70e216548 100644 --- a/tests/testthat/test-shinytest2-tm_t_tte.R +++ b/tests/testthat/test-shinytest2-tm_t_tte.R @@ -4,10 +4,7 @@ app_driver_tm_t_tte <- function() { ADSL <- teal.data::rADSL ADTTE <- teal.data::rADTTE }) - - datanames <- c("ADSL", "ADTTE") - teal.data::datanames(data) <- datanames - teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames] + teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)] arm_ref_comp <- list( ACTARMCD = list(