From b5c3b8a64823fc2b9b1ec6954762fdfa379ccaee Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Nov 2023 17:53:42 +0530 Subject: [PATCH 01/10] refactoring cdisc_dataset() call to return teal_data() --- R/tm_a_gee.R | 4 ++-- R/tm_a_mmrm.R | 4 ++-- R/tm_g_barchart_simple.R | 4 ++-- R/tm_g_ci.R | 4 ++-- R/tm_g_forest_rsp.R | 4 ++-- R/tm_g_forest_tte.R | 4 ++-- R/tm_g_ipp.R | 4 ++-- R/tm_g_km.R | 4 ++-- R/tm_g_lineplot.R | 4 ++-- R/tm_g_pp_adverse_events.R | 4 ++-- R/tm_g_pp_patient_timeline.R | 6 +++--- R/tm_g_pp_therapy.R | 4 ++-- R/tm_g_pp_vitals.R | 4 ++-- R/tm_t_abnormality.R | 4 ++-- R/tm_t_abnormality_by_worst_grade.R | 4 ++-- R/tm_t_ancova.R | 4 ++-- R/tm_t_binary_outcome.R | 4 ++-- R/tm_t_coxreg.R | 13 ++++--------- R/tm_t_events.R | 4 ++-- R/tm_t_events_by_grade.R | 4 ++-- R/tm_t_events_patyear.R | 4 ++-- R/tm_t_events_summary.R | 4 ++-- R/tm_t_exposure.R | 4 ++-- R/tm_t_logistic.R | 4 ++-- R/tm_t_mult_events.R | 4 ++-- R/tm_t_pp_basic_info.R | 2 +- R/tm_t_pp_laboratory.R | 4 ++-- R/tm_t_pp_medical_history.R | 4 ++-- R/tm_t_pp_prior_medication.R | 4 ++-- R/tm_t_shift_by_arm.R | 4 ++-- R/tm_t_shift_by_arm_by_worst.R | 4 ++-- R/tm_t_shift_by_grade.R | 4 ++-- R/tm_t_smq.R | 4 ++-- R/tm_t_summary.R | 2 +- R/tm_t_summary_by.R | 4 ++-- R/tm_t_tte.R | 4 ++-- man/template_g_lineplot.Rd | 10 ++++------ man/tm_a_gee.Rd | 4 ++-- man/tm_a_mmrm.Rd | 4 ++-- man/tm_g_barchart_simple.Rd | 4 ++-- man/tm_g_ci.Rd | 4 ++-- man/tm_g_forest_rsp.Rd | 4 ++-- man/tm_g_forest_tte.Rd | 4 ++-- man/tm_g_ipp.Rd | 4 ++-- man/tm_g_km.Rd | 4 ++-- man/tm_g_lineplot.Rd | 14 ++++++-------- man/tm_g_pp_adverse_events.Rd | 4 ++-- man/tm_g_pp_patient_timeline.Rd | 6 +++--- man/tm_g_pp_therapy.Rd | 4 ++-- man/tm_g_pp_vitals.Rd | 4 ++-- man/tm_t_abnormality.Rd | 4 ++-- man/tm_t_abnormality_by_worst_grade.Rd | 4 ++-- man/tm_t_ancova.Rd | 4 ++-- man/tm_t_binary_outcome.Rd | 4 ++-- man/tm_t_coxreg.Rd | 13 ++++--------- man/tm_t_events.Rd | 4 ++-- man/tm_t_events_by_grade.Rd | 4 ++-- man/tm_t_events_patyear.Rd | 4 ++-- man/tm_t_events_summary.Rd | 4 ++-- man/tm_t_exposure.Rd | 4 ++-- man/tm_t_logistic.Rd | 4 ++-- man/tm_t_mult_events.Rd | 4 ++-- man/tm_t_pp_basic_info.Rd | 2 +- man/tm_t_pp_laboratory.Rd | 4 ++-- man/tm_t_pp_medical_history.Rd | 4 ++-- man/tm_t_pp_prior_medication.Rd | 4 ++-- man/tm_t_shift_by_arm.Rd | 4 ++-- man/tm_t_shift_by_arm_by_worst.Rd | 4 ++-- man/tm_t_shift_by_grade.Rd | 4 ++-- man/tm_t_smq.Rd | 4 ++-- man/tm_t_summary.Rd | 2 +- man/tm_t_summary_by.Rd | 4 ++-- man/tm_t_tte.Rd | 4 ++-- vignettes/teal-modules-clinical.Rmd | 12 ++++++------ 74 files changed, 160 insertions(+), 174 deletions(-) diff --git a/R/tm_a_gee.R b/R/tm_a_gee.R index 838da724b4..58d4ec58cc 100644 --- a/R/tm_a_gee.R +++ b/R/tm_a_gee.R @@ -143,8 +143,8 @@ template_a_gee <- function(output_table, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADQS", adqs) +#' ADSL = adsl, +#' ADQS = adqs #' ), #' modules = modules( #' tm_a_gee( diff --git a/R/tm_a_mmrm.R b/R/tm_a_mmrm.R index d6dc606fc1..2cb0d43c7a 100644 --- a/R/tm_a_mmrm.R +++ b/R/tm_a_mmrm.R @@ -473,8 +473,8 @@ template_mmrm_plots <- function(fit_name, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADQS", adqs) +#' ADSL = adsl, +#' ADQS = adqs #' ), #' modules = modules( #' tm_a_mmrm( diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index 5419e8a4fa..e0e0f4e6d1 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -22,8 +22,8 @@ #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae) +#' ADSL = adsl, +#' ADAE = adae #' ), #' modules = modules( #' tm_g_barchart_simple( diff --git a/R/tm_g_ci.R b/R/tm_g_ci.R index 17f69b5d00..6885a8144d 100644 --- a/R/tm_g_ci.R +++ b/R/tm_g_ci.R @@ -197,8 +197,8 @@ template_g_ci <- function(dataname, # nolint #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_g_ci( diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index 24f2a5b899..fcc777827f 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -236,8 +236,8 @@ template_forest_rsp <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADRS", adrs) +#' ADSL = adsl, +#' ADRS = adrs #' ), #' modules = modules( #' tm_g_forest_rsp( diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index e87bb051f2..10326de727 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -243,8 +243,8 @@ template_forest_tte <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADTTE", adtte) +#' ADSL = adsl, +#' ADTTE = adtte #' ), #' modules = modules( #' tm_g_forest_tte( diff --git a/R/tm_g_ipp.R b/R/tm_g_ipp.R index c8e51e2935..5b85323057 100644 --- a/R/tm_g_ipp.R +++ b/R/tm_g_ipp.R @@ -196,8 +196,8 @@ template_g_ipp <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_g_ipp( diff --git a/R/tm_g_km.R b/R/tm_g_km.R index 874f361ced..63c1545a8c 100644 --- a/R/tm_g_km.R +++ b/R/tm_g_km.R @@ -263,8 +263,8 @@ template_g_km <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADTTE", adtte) +#' ADSL = adsl, +#' ADTTE = adtte #' ), #' modules = modules( #' tm_g_km( diff --git a/R/tm_g_lineplot.R b/R/tm_g_lineplot.R index 28e10102d4..9da46137d7 100644 --- a/R/tm_g_lineplot.R +++ b/R/tm_g_lineplot.R @@ -223,8 +223,8 @@ template_g_lineplot <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_g_lineplot( diff --git a/R/tm_g_pp_adverse_events.R b/R/tm_g_pp_adverse_events.R index bd2243b965..d7fc0842a1 100644 --- a/R/tm_g_pp_adverse_events.R +++ b/R/tm_g_pp_adverse_events.R @@ -196,8 +196,8 @@ template_adverse_events <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae) +#' ADSL = adsl, +#' ADAE = adae #' ), #' modules = modules( #' tm_g_pp_adverse_events( diff --git a/R/tm_g_pp_patient_timeline.R b/R/tm_g_pp_patient_timeline.R index 5655454b56..3a979c50f7 100644 --- a/R/tm_g_pp_patient_timeline.R +++ b/R/tm_g_pp_patient_timeline.R @@ -372,9 +372,9 @@ template_patient_timeline <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae), -#' cdisc_dataset("ADCM", adcm, keys = adcm_keys) +#' ADSL = adsl, +#' ADAE = adae, +#' ADCM = adcm # TODO use adcm_keys #' ), #' modules = modules( #' tm_g_pp_patient_timeline( diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index 9617eca52d..ee7e65d64e 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -271,8 +271,8 @@ template_therapy <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADCM", adcm, keys = adcm_keys) +#' ADSL = adsl, +#' ADCM = adcm # TODO use adcm_keys #' ), #' modules = modules( #' tm_g_pp_therapy( diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index e092a57afc..d74913a234 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -196,8 +196,8 @@ template_vitals <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADVS", advs) +#' ADSL = adsl, +#' ADVS = advs #' ), #' modules = modules( #' tm_g_pp_vitals( diff --git a/R/tm_t_abnormality.R b/R/tm_t_abnormality.R index ba732508a4..9cd2a4f121 100644 --- a/R/tm_t_abnormality.R +++ b/R/tm_t_abnormality.R @@ -249,8 +249,8 @@ template_abnormality <- function(parentname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_t_abnormality( diff --git a/R/tm_t_abnormality_by_worst_grade.R b/R/tm_t_abnormality_by_worst_grade.R index e0b4512ee2..0da5623885 100644 --- a/R/tm_t_abnormality_by_worst_grade.R +++ b/R/tm_t_abnormality_by_worst_grade.R @@ -251,8 +251,8 @@ template_abnormality_by_worst_grade <- function(parentname, # nolint #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_t_abnormality_by_worst_grade( diff --git a/R/tm_t_ancova.R b/R/tm_t_ancova.R index dcc31fb95a..8d919f36c1 100644 --- a/R/tm_t_ancova.R +++ b/R/tm_t_ancova.R @@ -445,8 +445,8 @@ template_ancova <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADQS", adqs) +#' ADSL = adsl, +#' ADQS = adqs #' ), #' modules = modules( #' tm_t_ancova( diff --git a/R/tm_t_binary_outcome.R b/R/tm_t_binary_outcome.R index 2ce52bab7d..bbbf93088f 100644 --- a/R/tm_t_binary_outcome.R +++ b/R/tm_t_binary_outcome.R @@ -407,8 +407,8 @@ template_binary_outcome <- function(dataname, #' ) #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADRS", adrs) +#' ADSL = adsl, +#' ADRS = adrs #' ), #' modules = modules( #' tm_t_binary_outcome( diff --git a/R/tm_t_coxreg.R b/R/tm_t_coxreg.R index 518b1d9654..14e98fd893 100644 --- a/R/tm_t_coxreg.R +++ b/R/tm_t_coxreg.R @@ -368,8 +368,8 @@ template_coxreg_m <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADTTE", adtte) +#' ADSL = adsl, +#' ADTTE = adtte #' ), #' modules = modules( #' tm_t_coxreg( @@ -439,13 +439,8 @@ template_coxreg_m <- function(dataname, #' arm_ref_comp <- list(ARMCD = list(ref = "ARM A", comp = c("ARM B"))) #' app <- init( #' data = cdisc_data( -#' cdisc_dataset( -#' dataname = "ADSL", -#' x = adsl -#' ), -#' cdisc_dataset( -#' dataname = "ADTTE", -#' x = adtte +#' ADSL = adsl, +#' ADTTE = adtte #' ) #' ), #' modules = modules( diff --git a/R/tm_t_events.R b/R/tm_t_events.R index 0eb62ab54e..cd2f86ca94 100644 --- a/R/tm_t_events.R +++ b/R/tm_t_events.R @@ -452,8 +452,8 @@ template_events <- function(dataname, #' #' app <- teal::init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae) +#' ADSL = adsl, +#' ADAE = adae #' ), #' modules = modules( #' tm_t_events( diff --git a/R/tm_t_events_by_grade.R b/R/tm_t_events_by_grade.R index bf3e1a6c94..cea556202f 100644 --- a/R/tm_t_events_by_grade.R +++ b/R/tm_t_events_by_grade.R @@ -791,8 +791,8 @@ template_events_col_by_grade <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae) +#' ADSL = adsl, +#' ADAE = adae #' ), #' modules = modules( #' tm_t_events_by_grade( diff --git a/R/tm_t_events_patyear.R b/R/tm_t_events_patyear.R index 1c5c6661ac..33add65b7c 100644 --- a/R/tm_t_events_patyear.R +++ b/R/tm_t_events_patyear.R @@ -160,8 +160,8 @@ template_events_patyear <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAETTE", adaette) +#' ADSL = adsl, +#' ADAETTE = adaette #' ), #' modules = modules( #' tm_t_events_patyear( diff --git a/R/tm_t_events_summary.R b/R/tm_t_events_summary.R index 2a86d6c01a..0ae66c1306 100644 --- a/R/tm_t_events_summary.R +++ b/R/tm_t_events_summary.R @@ -535,8 +535,8 @@ template_events_summary <- function(anl_name, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae) +#' ADSL = adsl, +#' ADAE = adae #' ), #' modules = modules( #' tm_t_events_summary( diff --git a/R/tm_t_exposure.R b/R/tm_t_exposure.R index ef2b2a3b98..3d6e071ff8 100644 --- a/R/tm_t_exposure.R +++ b/R/tm_t_exposure.R @@ -243,8 +243,8 @@ template_exposure <- function(parentname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADEX", adex) +#' ADSL = adsl, +#' ADEX = adex #' ), #' modules = modules( #' tm_t_exposure( diff --git a/R/tm_t_logistic.R b/R/tm_t_logistic.R index 8afbde897e..2dee5ce2d3 100644 --- a/R/tm_t_logistic.R +++ b/R/tm_t_logistic.R @@ -245,8 +245,8 @@ template_logistic <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADRS", adrs) +#' ADSL = adsl, +#' ADRS = adrs #' ), #' modules = modules( #' tm_t_logistic( diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index 809a0b7d50..4dd25f3ea8 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -286,8 +286,8 @@ template_mult_events <- function(dataname, #' #' app <- teal::init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADCM", adcm, keys = adcm_keys) +#' ADSL = adsl, +#' ADCM = adcm # TODO use adcm_keys #' ), #' modules = modules( #' tm_t_mult_events( diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index d9e45950cb..520c55328c 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -69,7 +69,7 @@ template_basic_info <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl) +#' ADSL = adsl #' ), #' modules = modules( #' tm_t_pp_basic_info( diff --git a/R/tm_t_pp_laboratory.R b/R/tm_t_pp_laboratory.R index 1773bd1d72..fd1a16b1bc 100644 --- a/R/tm_t_pp_laboratory.R +++ b/R/tm_t_pp_laboratory.R @@ -123,8 +123,8 @@ template_laboratory <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_t_pp_laboratory( diff --git a/R/tm_t_pp_medical_history.R b/R/tm_t_pp_medical_history.R index 2fa4ca639f..d3a92a7195 100644 --- a/R/tm_t_pp_medical_history.R +++ b/R/tm_t_pp_medical_history.R @@ -94,8 +94,8 @@ template_medical_history <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADMH", admh) +#' ADSL = adsl, +#' ADMH = admh #' ), #' modules = modules( #' tm_t_pp_medical_history( diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index 8e009acbfc..60987c6385 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -80,8 +80,8 @@ template_prior_medication <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADCM", adcm, keys = adcm_keys) +#' ADSL = adsl, +#' ADCM = adcm #' ), #' modules = modules( #' tm_t_pp_prior_medication( diff --git a/R/tm_t_shift_by_arm.R b/R/tm_t_shift_by_arm.R index ab78b47ea2..24216ca671 100644 --- a/R/tm_t_shift_by_arm.R +++ b/R/tm_t_shift_by_arm.R @@ -173,8 +173,8 @@ template_shift_by_arm <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADEG", adeg) +#' ADSL = adsl, +#' ADEG = adeg #' ), #' modules = modules( #' tm_t_shift_by_arm( diff --git a/R/tm_t_shift_by_arm_by_worst.R b/R/tm_t_shift_by_arm_by_worst.R index 403a13b22e..7f1c1b562d 100644 --- a/R/tm_t_shift_by_arm_by_worst.R +++ b/R/tm_t_shift_by_arm_by_worst.R @@ -181,8 +181,8 @@ template_shift_by_arm_by_worst <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADEG", adeg) +#' ADSL = adsl, +#' ADEG = adeg #' ), #' modules = modules( #' tm_t_shift_by_arm_by_worst( diff --git a/R/tm_t_shift_by_grade.R b/R/tm_t_shift_by_grade.R index 79bc855906..30b41724b0 100644 --- a/R/tm_t_shift_by_grade.R +++ b/R/tm_t_shift_by_grade.R @@ -483,8 +483,8 @@ template_shift_by_grade <- function(parentname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_t_shift_by_grade( diff --git a/R/tm_t_smq.R b/R/tm_t_smq.R index 6f787dc92f..289e8f63ec 100644 --- a/R/tm_t_smq.R +++ b/R/tm_t_smq.R @@ -337,8 +337,8 @@ template_smq <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADAE", adae) +#' ADSL = adsl, +#' ADAE = adae #' ), #' modules = modules( #' tm_t_smq( diff --git a/R/tm_t_summary.R b/R/tm_t_summary.R index 37a9fabc45..b9dc250c94 100644 --- a/R/tm_t_summary.R +++ b/R/tm_t_summary.R @@ -236,7 +236,7 @@ template_summary <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl) +#' ADSL = adsl #' ), #' modules = modules( #' tm_t_summary( diff --git a/R/tm_t_summary_by.R b/R/tm_t_summary_by.R index 88c4a7ad96..0ca1b12447 100644 --- a/R/tm_t_summary_by.R +++ b/R/tm_t_summary_by.R @@ -336,8 +336,8 @@ template_summary_by <- function(parentname, #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADLB", adlb) +#' ADSL = adsl, +#' ADLB = adlb #' ), #' modules = modules( #' tm_t_summary_by( diff --git a/R/tm_t_tte.R b/R/tm_t_tte.R index 40d8bd0dc7..6535b570fa 100644 --- a/R/tm_t_tte.R +++ b/R/tm_t_tte.R @@ -399,8 +399,8 @@ template_tte <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' cdisc_dataset("ADSL", adsl), -#' cdisc_dataset("ADTTE", adtte) +#' ADSL = adsl, +#' ADTTE = adtte #' ), #' modules = modules( #' tm_t_tte( diff --git a/man/template_g_lineplot.Rd b/man/template_g_lineplot.Rd index 1e6f07cc48..149a4fc47e 100644 --- a/man/template_g_lineplot.Rd +++ b/man/template_g_lineplot.Rd @@ -49,13 +49,11 @@ and be of a \code{double} or \code{numeric} type vector of length one.} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be -added to the plot.} +and be of a \code{double} or \code{numeric} type vector of length two.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names -of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of -\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting -\code{interval = NULL}.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} +attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, +lower or upper.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_a_gee.Rd b/man/tm_a_gee.Rd index 5d804fec80..01cac27aee 100644 --- a/man/tm_a_gee.Rd +++ b/man/tm_a_gee.Rd @@ -104,8 +104,8 @@ adqs <- tmc_ex_adqs \%>\% app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADQS", adqs) + ADSL = adsl, + ADQS = adqs ), modules = modules( tm_a_gee( diff --git a/man/tm_a_mmrm.Rd b/man/tm_a_mmrm.Rd index cc58cca6c1..ada3112294 100644 --- a/man/tm_a_mmrm.Rd +++ b/man/tm_a_mmrm.Rd @@ -145,8 +145,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADQS", adqs) + ADSL = adsl, + ADQS = adqs ), modules = modules( tm_a_mmrm( diff --git a/man/tm_g_barchart_simple.Rd b/man/tm_g_barchart_simple.Rd index b0be3df055..d63953c2d3 100644 --- a/man/tm_g_barchart_simple.Rd +++ b/man/tm_g_barchart_simple.Rd @@ -71,8 +71,8 @@ adae <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & ( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = modules( tm_g_barchart_simple( diff --git a/man/tm_g_ci.Rd b/man/tm_g_ci.Rd index 61d3db1735..a43baace6a 100644 --- a/man/tm_g_ci.Rd +++ b/man/tm_g_ci.Rd @@ -72,8 +72,8 @@ adlb <- tmc_ex_adlb app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_g_ci( diff --git a/man/tm_g_forest_rsp.Rd b/man/tm_g_forest_rsp.Rd index f5155a853f..44a656e38e 100644 --- a/man/tm_g_forest_rsp.Rd +++ b/man/tm_g_forest_rsp.Rd @@ -133,8 +133,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADRS", adrs) + ADSL = adsl, + ADRS = adrs ), modules = modules( tm_g_forest_rsp( diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index 67c8576944..35dbdfbade 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -136,8 +136,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADTTE", adtte) + ADSL = adsl, + ADTTE = adtte ), modules = modules( tm_g_forest_tte( diff --git a/man/tm_g_ipp.Rd b/man/tm_g_ipp.Rd index c87e6b9c36..12cfaf1671 100644 --- a/man/tm_g_ipp.Rd +++ b/man/tm_g_ipp.Rd @@ -116,8 +116,8 @@ adlb <- df_explicit_na(adlb) \%>\% dplyr::filter(AVISIT != "SCREENING") app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_g_ipp( diff --git a/man/tm_g_km.Rd b/man/tm_g_km.Rd index 4261808fa5..2c76589090 100644 --- a/man/tm_g_km.Rd +++ b/man/tm_g_km.Rd @@ -120,8 +120,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADTTE", adtte) + ADSL = adsl, + ADTTE = adtte ), modules = modules( tm_g_km( diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index 13b5e21b8e..f9949e233a 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -65,17 +65,15 @@ value for the confidence level within the range of (0, 1).} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be -added to the plot.} +and be of a \code{double} or \code{numeric} type vector of length two.} \item{mid}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as midpoints. All the statistics indicated in \code{mid} variable must be present in the object returned by \code{sfun}, and be of a \code{double} or \code{numeric} type vector of length one.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names -of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of -\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting -\code{interval = NULL}.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} +attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, +lower or upper.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} @@ -126,8 +124,8 @@ adlb <- tmc_ex_adlb \%>\% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, A app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_g_lineplot( diff --git a/man/tm_g_pp_adverse_events.Rd b/man/tm_g_pp_adverse_events.Rd index 877a889c6e..236922cdbc 100644 --- a/man/tm_g_pp_adverse_events.Rd +++ b/man/tm_g_pp_adverse_events.Rd @@ -95,8 +95,8 @@ adsl <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% adae$USUBJID) app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = modules( tm_g_pp_adverse_events( diff --git a/man/tm_g_pp_patient_timeline.Rd b/man/tm_g_pp_patient_timeline.Rd index cbfa1b6af0..860205d112 100644 --- a/man/tm_g_pp_patient_timeline.Rd +++ b/man/tm_g_pp_patient_timeline.Rd @@ -124,9 +124,9 @@ adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae), - cdisc_dataset("ADCM", adcm, keys = adcm_keys) + ADSL = adsl, + ADAE = adae, + ADCM = adcm # TODO use adcm_keys ), modules = modules( tm_g_pp_patient_timeline( diff --git a/man/tm_g_pp_therapy.Rd b/man/tm_g_pp_therapy.Rd index 5681ef4b11..dc28f85132 100644 --- a/man/tm_g_pp_therapy.Rd +++ b/man/tm_g_pp_therapy.Rd @@ -110,8 +110,8 @@ adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADCM", adcm, keys = adcm_keys) + ADSL = adsl, + ADCM = adcm # TODO use adcm_keys ), modules = modules( tm_g_pp_therapy( diff --git a/man/tm_g_pp_vitals.Rd b/man/tm_g_pp_vitals.Rd index 168b4f623d..dbe6f55c1a 100644 --- a/man/tm_g_pp_vitals.Rd +++ b/man/tm_g_pp_vitals.Rd @@ -79,8 +79,8 @@ advs <- tmc_ex_advs app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADVS", advs) + ADSL = adsl, + ADVS = advs ), modules = modules( tm_g_pp_vitals( diff --git a/man/tm_t_abnormality.Rd b/man/tm_t_abnormality.Rd index 7d258563d0..1913ab2d96 100644 --- a/man/tm_t_abnormality.Rd +++ b/man/tm_t_abnormality.Rd @@ -120,8 +120,8 @@ adlb <- tmc_ex_adlb \%>\% app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_t_abnormality( diff --git a/man/tm_t_abnormality_by_worst_grade.Rd b/man/tm_t_abnormality_by_worst_grade.Rd index 9579883e09..7336c46265 100644 --- a/man/tm_t_abnormality_by_worst_grade.Rd +++ b/man/tm_t_abnormality_by_worst_grade.Rd @@ -105,8 +105,8 @@ adlb <- tmc_ex_adlb \%>\% app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_t_abnormality_by_worst_grade( diff --git a/man/tm_t_ancova.Rd b/man/tm_t_ancova.Rd index 34b5cb26b6..0eaafd8821 100644 --- a/man/tm_t_ancova.Rd +++ b/man/tm_t_ancova.Rd @@ -125,8 +125,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADQS", adqs) + ADSL = adsl, + ADQS = adqs ), modules = modules( tm_t_ancova( diff --git a/man/tm_t_binary_outcome.Rd b/man/tm_t_binary_outcome.Rd index 75a5fb2054..90c1cb6659 100644 --- a/man/tm_t_binary_outcome.Rd +++ b/man/tm_t_binary_outcome.Rd @@ -137,8 +137,8 @@ arm_ref_comp <- list( ) app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADRS", adrs) + ADSL = adsl, + ADRS = adrs ), modules = modules( tm_t_binary_outcome( diff --git a/man/tm_t_coxreg.Rd b/man/tm_t_coxreg.Rd index 4f264fe69f..6ffa7aa9ff 100644 --- a/man/tm_t_coxreg.Rd +++ b/man/tm_t_coxreg.Rd @@ -148,8 +148,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADTTE", adtte) + ADSL = adsl, + ADTTE = adtte ), modules = modules( tm_t_coxreg( @@ -219,13 +219,8 @@ adsl <- subset( arm_ref_comp <- list(ARMCD = list(ref = "ARM A", comp = c("ARM B"))) app <- init( data = cdisc_data( - cdisc_dataset( - dataname = "ADSL", - x = adsl - ), - cdisc_dataset( - dataname = "ADTTE", - x = adtte + ADSL = adsl, + ADTTE = adtte ) ), modules = modules( diff --git a/man/tm_t_events.Rd b/man/tm_t_events.Rd index 8d60894e93..889b8fb314 100644 --- a/man/tm_t_events.Rd +++ b/man/tm_t_events.Rd @@ -93,8 +93,8 @@ adae <- tmc_ex_adae app <- teal::init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = modules( tm_t_events( diff --git a/man/tm_t_events_by_grade.Rd b/man/tm_t_events_by_grade.Rd index 6d80fddf6c..59a835b80d 100644 --- a/man/tm_t_events_by_grade.Rd +++ b/man/tm_t_events_by_grade.Rd @@ -97,8 +97,8 @@ formatters::var_labels(adae) <- lbls_adae app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = modules( tm_t_events_by_grade( diff --git a/man/tm_t_events_patyear.Rd b/man/tm_t_events_patyear.Rd index 5b90f4d5d7..80ad64c0a8 100644 --- a/man/tm_t_events_patyear.Rd +++ b/man/tm_t_events_patyear.Rd @@ -97,8 +97,8 @@ adaette <- tmc_ex_adaette \%>\% app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAETTE", adaette) + ADSL = adsl, + ADAETTE = adaette ), modules = modules( tm_t_events_patyear( diff --git a/man/tm_t_events_summary.Rd b/man/tm_t_events_summary.Rd index d8c757c45c..dd1c830f5b 100644 --- a/man/tm_t_events_summary.Rd +++ b/man/tm_t_events_summary.Rd @@ -149,8 +149,8 @@ aesi_vars <- names(adae)[startsWith(names(adae), "TMP_")] app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = modules( tm_t_events_summary( diff --git a/man/tm_t_exposure.Rd b/man/tm_t_exposure.Rd index 5ade73c864..8c6e8de616 100644 --- a/man/tm_t_exposure.Rd +++ b/man/tm_t_exposure.Rd @@ -120,8 +120,8 @@ formatters::var_labels(adex) <- labels app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADEX", adex) + ADSL = adsl, + ADEX = adex ), modules = modules( tm_t_exposure( diff --git a/man/tm_t_logistic.Rd b/man/tm_t_logistic.Rd index bed2464430..151c3455ed 100644 --- a/man/tm_t_logistic.Rd +++ b/man/tm_t_logistic.Rd @@ -96,8 +96,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADRS", adrs) + ADSL = adsl, + ADRS = adrs ), modules = modules( tm_t_logistic( diff --git a/man/tm_t_mult_events.Rd b/man/tm_t_mult_events.Rd index 7c7990ca53..cd9e1996d1 100644 --- a/man/tm_t_mult_events.Rd +++ b/man/tm_t_mult_events.Rd @@ -86,8 +86,8 @@ adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", app <- teal::init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADCM", adcm, keys = adcm_keys) + ADSL = adsl, + ADCM = adcm # TODO use adcm_keys ), modules = modules( tm_t_mult_events( diff --git a/man/tm_t_pp_basic_info.Rd b/man/tm_t_pp_basic_info.Rd index f23fb6cfa3..db5e877802 100644 --- a/man/tm_t_pp_basic_info.Rd +++ b/man/tm_t_pp_basic_info.Rd @@ -41,7 +41,7 @@ adsl <- tmc_ex_adsl app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl) + ADSL = adsl ), modules = modules( tm_t_pp_basic_info( diff --git a/man/tm_t_pp_laboratory.Rd b/man/tm_t_pp_laboratory.Rd index 6ec1c6fb94..1b7ffc2d4b 100644 --- a/man/tm_t_pp_laboratory.Rd +++ b/man/tm_t_pp_laboratory.Rd @@ -66,8 +66,8 @@ adlb <- tmc_ex_adlb app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_t_pp_laboratory( diff --git a/man/tm_t_pp_medical_history.Rd b/man/tm_t_pp_medical_history.Rd index 4024b00019..5ef48556c5 100644 --- a/man/tm_t_pp_medical_history.Rd +++ b/man/tm_t_pp_medical_history.Rd @@ -54,8 +54,8 @@ admh <- tmc_ex_admh app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADMH", admh) + ADSL = adsl, + ADMH = admh ), modules = modules( tm_t_pp_medical_history( diff --git a/man/tm_t_pp_prior_medication.Rd b/man/tm_t_pp_prior_medication.Rd index 11aeb96851..6ad8d78506 100644 --- a/man/tm_t_pp_prior_medication.Rd +++ b/man/tm_t_pp_prior_medication.Rd @@ -61,8 +61,8 @@ adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADCM", adcm, keys = adcm_keys) + ADSL = adsl, + ADCM = adcm ), modules = modules( tm_t_pp_prior_medication( diff --git a/man/tm_t_shift_by_arm.Rd b/man/tm_t_shift_by_arm.Rd index 62da975ab7..9608a67de4 100644 --- a/man/tm_t_shift_by_arm.Rd +++ b/man/tm_t_shift_by_arm.Rd @@ -101,8 +101,8 @@ adeg <- tmc_ex_adeg app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADEG", adeg) + ADSL = adsl, + ADEG = adeg ), modules = modules( tm_t_shift_by_arm( diff --git a/man/tm_t_shift_by_arm_by_worst.Rd b/man/tm_t_shift_by_arm_by_worst.Rd index f97212cdd8..5418951252 100644 --- a/man/tm_t_shift_by_arm_by_worst.Rd +++ b/man/tm_t_shift_by_arm_by_worst.Rd @@ -101,8 +101,8 @@ adeg <- tmc_ex_adeg app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADEG", adeg) + ADSL = adsl, + ADEG = adeg ), modules = modules( tm_t_shift_by_arm_by_worst( diff --git a/man/tm_t_shift_by_grade.Rd b/man/tm_t_shift_by_grade.Rd index 9bd99009f0..86c557179c 100644 --- a/man/tm_t_shift_by_grade.Rd +++ b/man/tm_t_shift_by_grade.Rd @@ -115,8 +115,8 @@ adlb <- tmc_ex_adlb app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_t_shift_by_grade( diff --git a/man/tm_t_smq.Rd b/man/tm_t_smq.Rd index 4422bb0715..b4577d8839 100644 --- a/man/tm_t_smq.Rd +++ b/man/tm_t_smq.Rd @@ -113,8 +113,8 @@ cs_scopes <- choices_selected( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = modules( tm_t_smq( diff --git a/man/tm_t_summary.Rd b/man/tm_t_summary.Rd index 31b7e1354a..19fa07b333 100644 --- a/man/tm_t_summary.Rd +++ b/man/tm_t_summary.Rd @@ -102,7 +102,7 @@ stopifnot( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl) + ADSL = adsl ), modules = modules( tm_t_summary( diff --git a/man/tm_t_summary_by.Rd b/man/tm_t_summary_by.Rd index c7950ce02e..3d3c057ddc 100644 --- a/man/tm_t_summary_by.Rd +++ b/man/tm_t_summary_by.Rd @@ -121,8 +121,8 @@ adlb <- tmc_ex_adlb app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADLB", adlb) + ADSL = adsl, + ADLB = adlb ), modules = modules( tm_t_summary_by( diff --git a/man/tm_t_tte.Rd b/man/tm_t_tte.Rd index 39165d7787..2ebccfece7 100644 --- a/man/tm_t_tte.Rd +++ b/man/tm_t_tte.Rd @@ -143,8 +143,8 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - cdisc_dataset("ADSL", adsl), - cdisc_dataset("ADTTE", adtte) + ADSL = adsl, + ADTTE = adtte ), modules = modules( tm_t_tte( diff --git a/vignettes/teal-modules-clinical.Rmd b/vignettes/teal-modules-clinical.Rmd index ad23a04e0a..3358c622a3 100644 --- a/vignettes/teal-modules-clinical.Rmd +++ b/vignettes/teal-modules-clinical.Rmd @@ -57,8 +57,8 @@ adae <- tmc_ex_adae app <- teal::init( data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", adsl), - teal.data::cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = list( tm_g_barchart_simple( @@ -80,7 +80,7 @@ if (interactive()) shiny::shinyApp(app$ui, app$server) `teal.modules.clinical` exports modules and needs support from other libraries to run a `teal` app and flesh out its functionality. In the example above, `tm_g_barchart_simple` is the only function from `teal.modules.clinical` where as `init` is a `teal` function, `data_extract_spec`, `select_spec` and `variable_choices` are `teal.transform` functions -and `cdisc_dataset` and `cdisc_data` are `teal.data` functions. +and `cdisc_data` are `teal.data` functions. Let's break the above app into pieces: @@ -103,8 +103,8 @@ argument indicates the modules included in the application. Here, we include onl ```r app <- teal::init( data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", adsl), - teal.data::cdisc_dataset("ADAE", adae) + ADSL = adsl, + ADAE = adae ), modules = list( tm_g_barchart_simple( @@ -128,7 +128,7 @@ Some of `teal.modules.clinical` modules allow specifying arguments using `teal.t ```r adsl <- tmc_ex_adsl app <- teal::init( - data = teal.data::cdisc_data(teal.data::cdisc_dataset("ADSL", adsl)), + data = teal.data::cdisc_data(ADSL = adsl), modules = list( tm_t_summary( label = "Demographic Table", From d79eff1fdcf47b3a9f2f541fdbfabc5213a8727a 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: Tue, 7 Nov 2023 12:33:13 +0000 Subject: [PATCH 02/10] [skip actions] Roxygen Man Pages Auto Update --- man/template_g_lineplot.Rd | 12 +++++++----- man/tm_g_lineplot.Rd | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/man/template_g_lineplot.Rd b/man/template_g_lineplot.Rd index 149a4fc47e..5c1e8881b8 100644 --- a/man/template_g_lineplot.Rd +++ b/man/template_g_lineplot.Rd @@ -30,7 +30,7 @@ template_g_lineplot( \item{dataname}{(\code{character})\cr analysis data used in teal module.} -\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} +\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -49,11 +49,13 @@ and be of a \code{double} or \code{numeric} type vector of length one.} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two.} +and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be +added to the plot.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} -attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, -lower or upper.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names +of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of +\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting +\code{interval = NULL}.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index f9949e233a..3e3668beeb 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -47,7 +47,7 @@ analysis data used in teal module.} \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} -\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} +\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -65,15 +65,17 @@ value for the confidence level within the range of (0, 1).} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two.} +and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be +added to the plot.} \item{mid}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as midpoints. All the statistics indicated in \code{mid} variable must be present in the object returned by \code{sfun}, and be of a \code{double} or \code{numeric} type vector of length one.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} -attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, -lower or upper.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names +of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of +\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting +\code{interval = NULL}.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} From 2bfb054b31363a433c7ec8060b01ef02531464de Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Nov 2023 14:41:00 +0530 Subject: [PATCH 03/10] adding code for reproducibility and updated news --- NEWS.md | 2 +- R/tm_a_gee.R | 41 ++++++------ R/tm_a_mmrm.R | 41 ++++++------ R/tm_g_barchart_simple.R | 27 ++++---- R/tm_g_ci.R | 22 ++++--- R/tm_g_forest_rsp.R | 27 +++++--- R/tm_g_forest_tte.R | 27 ++++---- R/tm_g_ipp.R | 35 +++++----- R/tm_g_km.R | 22 ++++--- R/tm_g_lineplot.R | 20 +++--- R/tm_g_pp_adverse_events.R | 26 ++++---- R/tm_g_pp_patient_timeline.R | 74 ++++++++++++--------- R/tm_g_pp_therapy.R | 45 ++++++++----- R/tm_g_pp_vitals.R | 20 +++--- R/tm_t_abnormality.R | 39 +++++------ R/tm_t_abnormality_by_worst_grade.R | 21 +++--- R/tm_t_ancova.R | 28 ++++---- R/tm_t_binary_outcome.R | 27 +++++--- R/tm_t_coxreg.R | 87 +++++++++++++------------ R/tm_t_events.R | 20 +++--- R/tm_t_events_by_grade.R | 32 +++++---- R/tm_t_events_patyear.R | 25 +++++--- R/tm_t_events_summary.R | 89 ++++++++++++++------------ R/tm_t_exposure.R | 52 ++++++++------- R/tm_t_logistic.R | 21 +++--- R/tm_t_mult_events.R | 21 +++--- R/tm_t_pp_basic_info.R | 9 +-- R/tm_t_pp_laboratory.R | 26 ++++---- R/tm_t_pp_medical_history.R | 20 +++--- R/tm_t_pp_prior_medication.R | 29 +++++---- R/tm_t_shift_by_arm.R | 26 ++++---- R/tm_t_shift_by_arm_by_worst.R | 28 ++++---- R/tm_t_shift_by_grade.R | 28 ++++---- R/tm_t_smq.R | 50 ++++++++------- R/tm_t_summary.R | 22 +++++-- R/tm_t_summary_by.R | 24 ++++--- R/tm_t_tte.R | 24 ++++--- man/tm_a_gee.Rd | 37 ++++++----- man/tm_a_mmrm.Rd | 37 ++++++----- man/tm_g_barchart_simple.Rd | 25 ++++---- man/tm_g_ci.Rd | 20 +++--- man/tm_g_forest_rsp.Rd | 23 ++++--- man/tm_g_forest_tte.Rd | 23 ++++--- man/tm_g_ipp.Rd | 31 +++++---- man/tm_g_km.Rd | 20 +++--- man/tm_g_lineplot.Rd | 18 ++++-- man/tm_g_pp_adverse_events.Rd | 24 ++++--- man/tm_g_pp_patient_timeline.Rd | 72 ++++++++++++--------- man/tm_g_pp_therapy.Rd | 43 ++++++++----- man/tm_g_pp_vitals.Rd | 18 ++++-- man/tm_t_abnormality.Rd | 35 +++++----- man/tm_t_abnormality_by_worst_grade.Rd | 17 +++-- man/tm_t_ancova.Rd | 24 ++++--- man/tm_t_binary_outcome.Rd | 23 +++++-- man/tm_t_coxreg.Rd | 85 +++++++++++++----------- man/tm_t_events.Rd | 16 +++-- man/tm_t_events_by_grade.Rd | 28 ++++---- man/tm_t_events_patyear.Rd | 21 ++++-- man/tm_t_events_summary.Rd | 85 ++++++++++++------------ man/tm_t_exposure.Rd | 50 ++++++++------- man/tm_t_logistic.Rd | 17 +++-- man/tm_t_mult_events.Rd | 17 +++-- man/tm_t_pp_basic_info.Rd | 7 +- man/tm_t_pp_laboratory.Rd | 24 ++++--- man/tm_t_pp_medical_history.Rd | 18 ++++-- man/tm_t_pp_prior_medication.Rd | 27 +++++--- man/tm_t_shift_by_arm.Rd | 22 ++++--- man/tm_t_shift_by_arm_by_worst.Rd | 24 ++++--- man/tm_t_shift_by_grade.Rd | 24 ++++--- man/tm_t_smq.Rd | 46 +++++++------ man/tm_t_summary.Rd | 18 ++++-- man/tm_t_summary_by.Rd | 20 +++--- man/tm_t_tte.Rd | 20 +++--- 73 files changed, 1293 insertions(+), 943 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9a06e2cf3b..0977b53a1b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,7 +13,7 @@ * Updated `tm_t_pp_basic_info`, `tm_t_pp_medical_history`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to print patient ID above table. * Updated `tm_t_pp_basic_info`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to use `rlistings` to print data neatly in reports. * Updated `tm_g_lineplot` to allow user to remove interval from plot. - +* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to teal::init(). ### Bug fixes * Fixed bug in `tm_t_coxreg` preventing table from being displayed when no covariates are selected. diff --git a/R/tm_a_gee.R b/R/tm_a_gee.R index 58d4ec58cc..c975a7f452 100644 --- a/R/tm_a_gee.R +++ b/R/tm_a_gee.R @@ -128,24 +128,27 @@ template_a_gee <- function(output_table, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adqs <- tmc_ex_adqs %>% -#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>% -#' dplyr::mutate( -#' AVISIT = as.factor(AVISIT), -#' AVISITN = rank(AVISITN) %>% -#' as.factor() %>% -#' as.numeric() %>% -#' as.factor(), -#' AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint. -#' ) %>% -#' droplevels() +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' ADQS <- tmc_ex_adqs %>% +#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>% +#' dplyr::mutate( +#' AVISIT = as.factor(AVISIT), +#' AVISITN = rank(AVISITN) %>% +#' as.factor() %>% +#' as.numeric() %>% +#' as.factor(), +#' AVALBIN = AVAL < 50 #' Just as an example to get a binary endpoint. +#' ) %>% +#' droplevels() +#' }) +#' datanames <- c("ADSL", "ADQS") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADQS = adqs -#' ), +#' data = data, #' modules = modules( #' tm_a_gee( #' label = "GEE", @@ -155,7 +158,7 @@ template_a_gee <- function(output_table, #' arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), #' visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"), #' paramcd = choices_selected( -#' choices = value_choices(adqs, "PARAMCD", "PARAM"), +#' choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), #' selected = "FKSI-FWB" #' ), #' cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL) @@ -444,14 +447,14 @@ srv_gee <- function(id, datasets = data, selector_list = selector_list, merge_function = "dplyr::inner_join", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) anl_q <- shiny::reactive({ diff --git a/R/tm_a_mmrm.R b/R/tm_a_mmrm.R index 2cb0d43c7a..b743eb392a 100644 --- a/R/tm_a_mmrm.R +++ b/R/tm_a_mmrm.R @@ -452,18 +452,6 @@ template_mmrm_plots <- function(fit_name, #' numerical precision. #' #' @examples -#' adsl <- tmc_ex_adsl -#' adqs <- tmc_ex_adqs %>% -#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>% -#' dplyr::filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) %>% -#' dplyr::mutate( -#' AVISIT = as.factor(AVISIT), -#' AVISITN = rank(AVISITN) %>% -#' as.factor() %>% -#' as.numeric() %>% -#' as.factor() # making consecutive numeric factor -#' ) -#' #' arm_ref_comp <- list( #' ARMCD = list( #' ref = "ARM B", @@ -471,11 +459,26 @@ template_mmrm_plots <- function(fit_name, #' ) #' ) #' +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' ADQS <- tmc_ex_adqs %>% +#' dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") %>% +#' dplyr::filter(AVISIT %in% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) %>% +#' dplyr::mutate( +#' AVISIT = as.factor(AVISIT), +#' AVISITN = rank(AVISITN) %>% +#' as.factor() %>% +#' as.numeric() %>% +#' as.factor() #' making consecutive numeric factor +#' ) +#' }) +#' +#' datanames <- c("ADSL", "ADQS") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADQS = adqs -#' ), +#' data = data, #' modules = modules( #' tm_a_mmrm( #' label = "MMRM", @@ -486,7 +489,7 @@ template_mmrm_plots <- function(fit_name, #' visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' choices = value_choices(adqs, "PARAMCD", "PARAM"), +#' choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), #' selected = "FKSI-FWB" #' ), #' cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL) @@ -917,14 +920,14 @@ srv_mmrm <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list_without_cov, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_merge_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index e0e0f4e6d1..2c6e08ca63 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -16,14 +16,17 @@ #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor("Y") %>% +#' ADSL <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor("Y") %>% #' formatters::with_label("Intent-To-Treat Population Flag")) -#' adae <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) +#' ADAE <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae +#' ADSL = ADSL, +#' ADAE = ADAE, +#' code = "ADSL <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor(\"Y\") %>% +#' formatters::with_label(\"Intent-To-Treat Population Flag\")) +#' ADAE <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))" #' ), #' modules = modules( #' tm_g_barchart_simple( @@ -32,7 +35,7 @@ #' dataname = "ADSL", #' select = select_spec( #' choices = variable_choices( -#' adsl, +#' ADSL, #' c( #' "ARM", "ACTARM", "SEX", #' "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -47,7 +50,7 @@ #' dataname = "ADSL", #' select = select_spec( #' choices = variable_choices( -#' adsl, +#' ADSL, #' c( #' "ARM", "ACTARM", "SEX", #' "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -60,7 +63,7 @@ #' data_extract_spec( #' dataname = "ADAE", #' select = select_spec( -#' choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")), +#' choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")), #' selected = NULL, #' multiple = FALSE #' ) @@ -70,7 +73,7 @@ #' data_extract_spec( #' dataname = "ADAE", #' select = select_spec( -#' choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")), +#' choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")), #' selected = "AETOXGR", #' multiple = FALSE #' ) @@ -79,7 +82,7 @@ #' dataname = "ADSL", #' select = select_spec( #' choices = variable_choices( -#' adsl, +#' ADSL, #' c( #' "ARM", "ACTARM", "SEX", #' "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -94,7 +97,7 @@ #' data_extract_spec( #' dataname = "ADAE", #' select = select_spec( -#' choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")), +#' choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")), #' selected = "AESEV", #' multiple = FALSE #' ) @@ -103,7 +106,7 @@ #' dataname = "ADSL", #' select = select_spec( #' choices = variable_choices( -#' adsl, +#' ADSL, #' c( #' "ARM", "ACTARM", "SEX", #' "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -374,7 +377,7 @@ srv_g_barchart_simple <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list ) diff --git a/R/tm_g_ci.R b/R/tm_g_ci.R index 6885a8144d..e7c4ea1897 100644 --- a/R/tm_g_ci.R +++ b/R/tm_g_ci.R @@ -192,13 +192,17 @@ template_g_ci <- function(dataname, # nolint #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb +#' " #' ), #' modules = modules( #' tm_g_ci( @@ -217,15 +221,15 @@ template_g_ci <- function(dataname, # nolint #' filter = list( #' filter_spec( #' vars = "PARAMCD", -#' choices = levels(adlb$PARAMCD), -#' selected = levels(adlb$PARAMCD)[1], +#' choices = levels(ADLB$PARAMCD), +#' selected = levels(ADLB$PARAMCD)[1], #' multiple = FALSE, #' label = "Select lab:" #' ), #' filter_spec( #' vars = "AVISIT", -#' choices = levels(adlb$AVISIT), -#' selected = levels(adlb$AVISIT)[1], +#' choices = levels(ADLB$AVISIT), +#' selected = levels(ADLB$AVISIT)[1], #' multiple = FALSE, #' label = "Select visit:" #' ) @@ -399,7 +403,7 @@ srv_g_ci <- function(id, # nolint anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list ) diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index fcc777827f..141cfcb3e5 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -217,8 +217,8 @@ template_forest_rsp <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl -#' adrs <- tmc_ex_adrs %>% +#' ADSL <- tmc_ex_adsl +#' ADRS <- tmc_ex_adrs %>% #' dplyr::mutate(AVALC = tern::d_onco_rsp_label(AVALC) %>% #' formatters::with_label("Character Result/Finding")) %>% #' dplyr::filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") @@ -236,28 +236,35 @@ template_forest_rsp <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADRS = adrs +#' ADSL = ADSL, +#' ADRS = ADRS, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADRS <- tmc_ex_adrs %>% +#' dplyr::mutate(AVALC = tern::d_onco_rsp_label(AVALC) %>% +#' formatters::with_label(\"Character Result/Finding\")) %>% +#' dplyr::filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\") +#' " #' ), #' modules = modules( #' tm_g_forest_rsp( #' label = "Forest Response", #' dataname = "ADRS", #' arm_var = choices_selected( -#' variable_choices(adsl, c("ARM", "ARMCD")), +#' variable_choices(ADSL, c("ARM", "ARMCD")), #' "ARMCD" #' ), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' value_choices(adrs, "PARAMCD", "PARAM"), +#' value_choices(ADRS, "PARAMCD", "PARAM"), #' "INVET" #' ), #' subgroup_var = choices_selected( -#' variable_choices(adsl, names(adsl)), +#' variable_choices(ADSL, names(ADSL)), #' c("BMRKR2", "SEX") #' ), #' strata_var = choices_selected( -#' variable_choices(adsl, c("STRATA1", "STRATA2")), +#' variable_choices(ADSL, c("STRATA1", "STRATA2")), #' "STRATA2" #' ), #' plot_height = c(600L, 200L, 2000L), @@ -514,13 +521,13 @@ srv_g_forest_rsp <- function(id, datasets = data, selector_list = selector_list, merge_function = "dplyr::inner_join", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var, subgroup_var = subgroup_var, strata_var = strata_var), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index 10326de727..2662bbedc6 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -226,9 +226,9 @@ template_forest_tte <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl -#' adtte <- tmc_ex_adtte -#' adsl$RACE <- droplevels(adsl$RACE) %>% formatters::with_label("Race") +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte +#' ADSL$RACE <- droplevels(ADSL$RACE) %>% formatters::with_label("Race") #' #' arm_ref_comp <- list( #' ARM = list( @@ -243,28 +243,33 @@ template_forest_tte <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADTTE = adtte +#' ADSL = ADSL, +#' ADTTE = ADTTE, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte +#' ADSL$RACE <- droplevels(ADSL$RACE) %>% formatters::with_label(\"Race\") +#' " #' ), #' modules = modules( #' tm_g_forest_tte( #' label = "Forest Survival", #' dataname = "ADTTE", #' arm_var = choices_selected( -#' variable_choices(adsl, c("ARM", "ARMCD")), +#' variable_choices(ADSL, c("ARM", "ARMCD")), #' "ARMCD" #' ), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' value_choices(adtte, "PARAMCD", "PARAM"), +#' value_choices(ADTTE, "PARAMCD", "PARAM"), #' "OS" #' ), #' subgroup_var = choices_selected( -#' variable_choices(adsl, names(adsl)), +#' variable_choices(ADSL, names(ADSL)), #' c("BMRKR2", "SEX") #' ), #' strata_var = choices_selected( -#' variable_choices(adsl, c("STRATA1", "STRATA2")), +#' variable_choices(ADSL, c("STRATA1", "STRATA2")), #' "STRATA2" #' ), #' plot_height = c(600, 200, 2000) @@ -517,14 +522,14 @@ srv_g_forest_tte <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var, subgroup_var = subgroup_var, strata_var = strata_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_g_ipp.R b/R/tm_g_ipp.R index 5b85323057..fa88483485 100644 --- a/R/tm_g_ipp.R +++ b/R/tm_g_ipp.R @@ -188,49 +188,52 @@ template_g_ipp <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl %>% dplyr::slice(1:20) -#' adlb <- tmc_ex_adlb %>% dplyr::filter(USUBJID %in% adsl$USUBJID) -#' -#' adsl <- df_explicit_na(adsl) -#' adlb <- df_explicit_na(adlb) %>% dplyr::filter(AVISIT != "SCREENING") +#' ADSL <- tmc_ex_adsl %>% dplyr::slice(1:20) %>% df_explicit_na() +#' ADLB <- tmc_ex_adlb %>% dplyr::filter(USUBJID %in% ADSL$USUBJID) %>% +#' df_explicit_na() %>% dplyr::filter(AVISIT != "SCREENING") #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl %>% dplyr::slice(1:20) %>% df_explicit_na() +#' ADLB <- tmc_ex_adlb %>% dplyr::filter(USUBJID %in% ADSL$USUBJID) %>% +#' df_explicit_na() %>% dplyr::filter(AVISIT != \"SCREENING\") +#' " #' ), #' modules = modules( #' tm_g_ipp( #' label = "Individual Patient Plot", #' dataname = "ADLB", #' arm_var = choices_selected( -#' value_choices(adlb, "ARMCD"), +#' value_choices(ADLB, "ARMCD"), #' "ARM A" #' ), #' paramcd = choices_selected( -#' value_choices(adlb, "PARAMCD"), +#' value_choices(ADLB, "PARAMCD"), #' "ALT" #' ), #' aval_var = choices_selected( -#' variable_choices(adlb, c("AVAL", "CHG")), +#' variable_choices(ADLB, c("AVAL", "CHG")), #' "AVAL" #' ), #' avalu_var = choices_selected( -#' variable_choices(adlb, c("AVALU")), +#' variable_choices(ADLB, c("AVALU")), #' "AVALU", #' fixed = TRUE #' ), #' id_var = choices_selected( -#' variable_choices(adlb, c("USUBJID")), +#' variable_choices(ADLB, c("USUBJID")), #' "USUBJID", #' fixed = TRUE #' ), #' visit_var = choices_selected( -#' variable_choices(adlb, c("AVISIT")), +#' variable_choices(ADLB, c("AVISIT")), #' "AVISIT" #' ), #' base_var = choices_selected( -#' variable_choices(adlb, c("BASE")), +#' variable_choices(ADLB, c("BASE")), #' "BASE", #' fixed = TRUE #' ), @@ -492,12 +495,12 @@ srv_g_ipp <- function(id, datasets = data, selector_list = selector_list, merge_function = "dplyr::inner_join", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var, id_var = id_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_g_km.R b/R/tm_g_km.R index 63c1545a8c..9de6059fd0 100644 --- a/R/tm_g_km.R +++ b/R/tm_g_km.R @@ -247,8 +247,8 @@ template_g_km <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl -#' adtte <- tmc_ex_adtte +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte #' #' arm_ref_comp <- list( #' ACTARMCD = list( @@ -263,28 +263,32 @@ template_g_km <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADTTE = adtte +#' ADSL = ADSL, +#' ADTTE = ADTTE, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte +#' " #' ), #' modules = modules( #' tm_g_km( #' label = "Kaplan-Meier Plot", #' dataname = "ADTTE", #' arm_var = choices_selected( -#' variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")), +#' variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), #' "ARM" #' ), #' paramcd = choices_selected( -#' value_choices(adtte, "PARAMCD", "PARAM"), +#' value_choices(ADTTE, "PARAMCD", "PARAM"), #' "OS" #' ), #' arm_ref_comp = arm_ref_comp, #' strata_var = choices_selected( -#' variable_choices(adsl, c("SEX", "BMRKR2")), +#' variable_choices(ADSL, c("SEX", "BMRKR2")), #' "SEX" #' ), #' facet_var = choices_selected( -#' variable_choices(adsl, c("SEX", "BMRKR2")), +#' variable_choices(ADSL, c("SEX", "BMRKR2")), #' NULL #' ) #' ) @@ -652,7 +656,7 @@ srv_g_km <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) diff --git a/R/tm_g_lineplot.R b/R/tm_g_lineplot.R index 9da46137d7..ea24026228 100644 --- a/R/tm_g_lineplot.R +++ b/R/tm_g_lineplot.R @@ -218,28 +218,32 @@ template_g_lineplot <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb %>% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)) +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb %>% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)) #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb %>% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)) +#' " #' ), #' modules = modules( #' tm_g_lineplot( #' label = "Line Plot", #' dataname = "ADLB", #' strata = choices_selected( -#' variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")), +#' variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), #' "ARM" #' ), #' y = choices_selected( -#' variable_choices(adlb, c("AVAL", "BASE", "CHG", "PCHG")), +#' variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")), #' "AVAL" #' ), #' param = choices_selected( -#' value_choices(adlb, "PARAMCD", "PARAM"), +#' value_choices(ADLB, "PARAMCD", "PARAM"), #' "ALT" #' ) #' ) @@ -551,7 +555,7 @@ srv_g_lineplot <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) diff --git a/R/tm_g_pp_adverse_events.R b/R/tm_g_pp_adverse_events.R index d7fc0842a1..05d3829a34 100644 --- a/R/tm_g_pp_adverse_events.R +++ b/R/tm_g_pp_adverse_events.R @@ -191,13 +191,17 @@ template_adverse_events <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adae <- tmc_ex_adae -#' adsl <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% adae$USUBJID) +#' ADAE <- tmc_ex_adae +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADAE$USUBJID) #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae +#' ADSL = ADSL, +#' ADAE = ADAE, +#' code = " +#' ADAE <- tmc_ex_adae +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADAE$USUBJID) +#' " #' ), #' modules = modules( #' tm_g_pp_adverse_events( @@ -207,27 +211,27 @@ template_adverse_events <- function(dataname = "ANL", #' patient_col = "USUBJID", #' plot_height = c(600L, 200L, 2000L), #' aeterm = choices_selected( -#' choices = variable_choices(adae, "AETERM"), +#' choices = variable_choices(ADAE, "AETERM"), #' selected = "AETERM" #' ), #' tox_grade = choices_selected( -#' choices = variable_choices(adae, "AETOXGR"), +#' choices = variable_choices(ADAE, "AETOXGR"), #' selected = "AETOXGR" #' ), #' causality = choices_selected( -#' choices = variable_choices(adae, "AEREL"), +#' choices = variable_choices(ADAE, "AEREL"), #' selected = "AEREL" #' ), #' outcome = choices_selected( -#' choices = variable_choices(adae, "AEOUT"), +#' choices = variable_choices(ADAE, "AEOUT"), #' selected = "AEOUT" #' ), #' action = choices_selected( -#' choices = variable_choices(adae, "AEACN"), +#' choices = variable_choices(ADAE, "AEACN"), #' selected = "AEACN" #' ), #' time = choices_selected( -#' choices = variable_choices(adae, "ASTDY"), +#' choices = variable_choices(ADAE, "ASTDY"), #' selected = "ASTDY" #' ), #' decod = NULL @@ -492,7 +496,7 @@ srv_g_adverse_events <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) anl_q <- shiny::reactive( diff --git a/R/tm_g_pp_patient_timeline.R b/R/tm_g_pp_patient_timeline.R index 3a979c50f7..8b40e6fc79 100644 --- a/R/tm_g_pp_patient_timeline.R +++ b/R/tm_g_pp_patient_timeline.R @@ -352,30 +352,40 @@ template_patient_timeline <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adae <- tmc_ex_adae -#' adsl <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% adae$USUBJID) -#' adcm <- tmc_ex_adcm %>% dplyr::mutate( -#' CMSTDY = dplyr::case_when( -#' CMCAT == "medcl B" ~ 20, -#' CMCAT == "medcl C" ~ 150, -#' TRUE ~ 1 -#' ) %>% formatters::with_label("Study Day of Start of Medication"), -#' CMENDY = dplyr::case_when( -#' CMCAT == "medcl B" ~ 700, -#' CMCAT == "medcl C" ~ 1000, -#' TRUE ~ 500 -#' ) %>% formatters::with_label("Study Day of End of Medication"), -#' CMASTDTM = ASTDTM, -#' CMAENDTM = AENDTM -#' ) #' adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") #' +#' data <- teal_data() +#' data <- within(data, { +#' ADAE <- tmc_ex_adae +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADAE$USUBJID) +#' ADCM <- tmc_ex_adcm %>% dplyr::mutate( +#' CMSTDY = dplyr::case_when( +#' CMCAT == "medcl B" ~ 20, +#' CMCAT == "medcl C" ~ 150, +#' TRUE ~ 1 +#' ) %>% formatters::with_label("Study Day of Start of Medication"), +#' CMENDY = dplyr::case_when( +#' CMCAT == "medcl B" ~ 700, +#' CMCAT == "medcl C" ~ 1000, +#' TRUE ~ 500 +#' ) %>% formatters::with_label("Study Day of End of Medication"), +#' CMASTDTM = ASTDTM, +#' CMAENDTM = AENDTM +#' ) +#' }) +#' +#' datanames(data) <- c("ADSL", "ADAE", "ADCM") +#' data@join_keys <- join_keys( +#' join_key("ADSL",keys = get_cdisc_keys("ADSL")), +#' join_key("ADAE", keys = get_cdisc_keys("ADAE")), +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADAE", "ADSL", c("USUBJID", "STUDYID")), +#' join_key("ADAE", "ADCM", c("USUBJID", "STUDYID")), +#' join_key("ADCM", "ADSL", c("USUBJID", "STUDYID")), +#' ) +#' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae, -#' ADCM = adcm # TODO use adcm_keys -#' ), +#' data = data, #' modules = modules( #' tm_g_pp_patient_timeline( #' label = "Patient Timeline", @@ -385,43 +395,43 @@ template_patient_timeline <- function(dataname = "ANL", #' patient_col = "USUBJID", #' plot_height = c(600L, 200L, 2000L), #' cmdecod = choices_selected( -#' choices = variable_choices(adcm, "CMDECOD"), +#' choices = variable_choices(data[["ADCM"]], "CMDECOD"), #' selected = "CMDECOD", #' ), #' aeterm = choices_selected( -#' choices = variable_choices(adae, "AETERM"), +#' choices = variable_choices(data[["ADAE"]], "AETERM"), #' selected = c("AETERM") #' ), #' aetime_start = choices_selected( -#' choices = variable_choices(adae, "ASTDTM"), +#' choices = variable_choices(data[["ADAE"]], "ASTDTM"), #' selected = c("ASTDTM") #' ), #' aetime_end = choices_selected( -#' choices = variable_choices(adae, "AENDTM"), +#' choices = variable_choices(data[["ADAE"]], "AENDTM"), #' selected = c("AENDTM") #' ), #' dstime_start = choices_selected( -#' choices = variable_choices(adcm, "CMASTDTM"), +#' choices = variable_choices(data[["ADCM"]], "CMASTDTM"), #' selected = c("CMASTDTM") #' ), #' dstime_end = choices_selected( -#' choices = variable_choices(adcm, "CMAENDTM"), +#' choices = variable_choices(data[["ADCM"]], "CMAENDTM"), #' selected = c("CMAENDTM") #' ), #' aerelday_start = choices_selected( -#' choices = variable_choices(adae, "ASTDY"), +#' choices = variable_choices(data[["ADAE"]], "ASTDY"), #' selected = c("ASTDY") #' ), #' aerelday_end = choices_selected( -#' choices = variable_choices(adae, "AENDY"), +#' choices = variable_choices(data[["ADAE"]], "AENDY"), #' selected = c("AENDY") #' ), #' dsrelday_start = choices_selected( -#' choices = variable_choices(adcm, "ASTDY"), +#' choices = variable_choices(data[["ADCM"]], "ASTDY"), #' selected = c("ASTDY") #' ), #' dsrelday_end = choices_selected( -#' choices = variable_choices(adcm, "AENDY"), +#' choices = variable_choices(data[["ADCM"]], "AENDY"), #' selected = c("AENDY") #' ) #' ) @@ -762,7 +772,7 @@ srv_g_patient_timeline <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list ) diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index ee7e65d64e..36e651ebe0 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -263,16 +263,27 @@ template_therapy <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adcm <- tmc_ex_adcm -#' adsl <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% adcm$USUBJID) -#' adcm$CMASTDTM <- adcm$ASTDTM -#' adcm$CMAENDTM <- adcm$AENDTM +#' ADCM <- tmc_ex_adcm +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADCM$USUBJID) +#' ADCM$CMASTDTM <- ADCM$ASTDTM +#' ADCM$CMAENDTM <- ADCM$AENDTM #' adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADCM = adcm # TODO use adcm_keys +#' ADSL = ADSL, +#' ADCM = adcm, +#' code = " +#' ADCM <- tmc_ex_adcm +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADCM$USUBJID) +#' ADCM$CMASTDTM <- ADCM$ASTDTM +#' ADCM$CMAENDTM <- ADCM$AENDTM +#' ", +#' join_keys = join_keys( +#' join_key("ADSL", keys = get_cdisc_keys("ADSL")), +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) +#' ) #' ), #' modules = modules( #' tm_g_pp_therapy( @@ -282,43 +293,43 @@ template_therapy <- function(dataname = "ANL", #' patient_col = "USUBJID", #' plot_height = c(600L, 200L, 2000L), #' atirel = choices_selected( -#' choices = variable_choices(adcm, "ATIREL"), +#' choices = variable_choices(ADCM, "ATIREL"), #' selected = c("ATIREL") #' ), #' cmdecod = choices_selected( -#' choices = variable_choices(adcm, "CMDECOD"), +#' choices = variable_choices(ADCM, "CMDECOD"), #' selected = "CMDECOD" #' ), #' cmindc = choices_selected( -#' choices = variable_choices(adcm, "CMINDC"), +#' choices = variable_choices(ADCM, "CMINDC"), #' selected = "CMINDC" #' ), #' cmdose = choices_selected( -#' choices = variable_choices(adcm, "CMDOSE"), +#' choices = variable_choices(ADCM, "CMDOSE"), #' selected = "CMDOSE" #' ), #' cmtrt = choices_selected( -#' choices = variable_choices(adcm, "CMTRT"), +#' choices = variable_choices(ADCM, "CMTRT"), #' selected = "CMTRT" #' ), #' cmdosu = choices_selected( -#' choices = variable_choices(adcm, "CMDOSU"), +#' choices = variable_choices(ADCM, "CMDOSU"), #' selected = c("CMDOSU") #' ), #' cmroute = choices_selected( -#' choices = variable_choices(adcm, "CMROUTE"), +#' choices = variable_choices(ADCM, "CMROUTE"), #' selected = "CMROUTE" #' ), #' cmdosfrq = choices_selected( -#' choices = variable_choices(adcm, "CMDOSFRQ"), +#' choices = variable_choices(ADCM, "CMDOSFRQ"), #' selected = "CMDOSFRQ" #' ), #' cmstdy = choices_selected( -#' choices = variable_choices(adcm, "ASTDY"), +#' choices = variable_choices(ADCM, "ASTDY"), #' selected = "ASTDY" #' ), #' cmendy = choices_selected( -#' choices = variable_choices(adcm, "AENDY"), +#' choices = variable_choices(ADCM, "AENDY"), #' selected = "AENDY" #' ) #' ) @@ -602,7 +613,7 @@ srv_g_therapy <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index d74913a234..67905939a6 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -191,13 +191,17 @@ template_vitals <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' adsl <- tmc_ex_adsl -#' advs <- tmc_ex_advs +#' ADSL <- tmc_ex_adsl +#' ADVS <- tmc_ex_advs #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADVS = advs +#' ADSL = ADSL, +#' ADVS = ADVS, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADVS <- tmc_ex_advs +#' " #' ), #' modules = modules( #' tm_g_pp_vitals( @@ -207,15 +211,15 @@ template_vitals <- function(dataname = "ANL", #' patient_col = "USUBJID", #' plot_height = c(600L, 200L, 2000L), #' paramcd = choices_selected( -#' choices = variable_choices(advs, "PARAMCD"), +#' choices = variable_choices(ADVS, "PARAMCD"), #' selected = "PARAMCD" #' ), #' xaxis = choices_selected( -#' choices = variable_choices(advs, "ADY"), +#' choices = variable_choices(ADVS, "ADY"), #' selected = "ADY" #' ), #' aval = choices_selected( -#' choices = variable_choices(advs, "AVAL"), +#' choices = variable_choices(ADVS, "AVAL"), #' selected = "AVAL" #' ) #' ) @@ -425,7 +429,7 @@ srv_g_vitals <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) diff --git a/R/tm_t_abnormality.R b/R/tm_t_abnormality.R index 9cd2a4f121..96fb2f1666 100644 --- a/R/tm_t_abnormality.R +++ b/R/tm_t_abnormality.R @@ -238,40 +238,43 @@ template_abnormality <- function(parentname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb %>% -#' dplyr::mutate( -#' ONTRTFL = dplyr::case_when( -#' AVISIT %in% c("SCREENING", "BASELINE") ~ "", -#' TRUE ~ "Y" -#' ) %>% formatters::with_label("On Treatment Record Flag") -#' ) +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb %>% +#' dplyr::mutate( +#' ONTRTFL = dplyr::case_when( +#' AVISIT %in% c("SCREENING", "BASELINE") ~ "", +#' TRUE ~ "Y" +#' ) %>% formatters::with_label("On Treatment Record Flag") +#' ) +#' }) +#' datanames <- c("ADSL", "ADLB") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb -#' ), +#' data = data, #' modules = modules( #' tm_t_abnormality( #' label = "Abnormality Table", #' dataname = "ADLB", #' arm_var = choices_selected( -#' choices = variable_choices(adsl, subset = c("ARM", "ARMCD")), +#' choices = variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' add_total = FALSE, #' by_vars = choices_selected( -#' choices = variable_choices(adlb, subset = c("LBCAT", "PARAM", "AVISIT")), +#' choices = variable_choices(data[["ADLB"]], subset = c("LBCAT", "PARAM", "AVISIT")), #' selected = c("LBCAT", "PARAM"), #' keep_order = TRUE #' ), #' baseline_var = teal.transform::choices_selected( -#' teal.transform::variable_choices(adlb, subset = "BNRIND"), +#' teal.transform::variable_choices(data[["ADLB"]], subset = "BNRIND"), #' selected = "BNRIND", fixed = TRUE #' ), #' grade = choices_selected( -#' choices = variable_choices(adlb, subset = "ANRIND"), +#' choices = variable_choices(data[["ADLB"]], subset = "ANRIND"), #' selected = "ANRIND", #' fixed = TRUE #' ), @@ -539,14 +542,14 @@ srv_t_abnormality <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_abnormality_by_worst_grade.R b/R/tm_t_abnormality_by_worst_grade.R index 0da5623885..e49738ef0d 100644 --- a/R/tm_t_abnormality_by_worst_grade.R +++ b/R/tm_t_abnormality_by_worst_grade.R @@ -245,25 +245,30 @@ template_abnormality_by_worst_grade <- function(parentname, # nolint #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb %>% +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb %>% #' dplyr::filter(!AVISIT %in% c("SCREENING", "BASELINE")) #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb %>% +#' dplyr::filter(!AVISIT %in% c(\"SCREENING\", \"BASELINE\")) +#' " #' ), #' modules = modules( #' tm_t_abnormality_by_worst_grade( #' label = "Laboratory Test Results with Highest Grade Post-Baseline", #' dataname = "ADLB", #' arm_var = choices_selected( -#' choices = variable_choices(adsl, subset = c("ARM", "ARMCD")), +#' choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' paramcd = choices_selected( -#' choices = value_choices(adlb, "PARAMCD", "PARAM"), +#' choices = value_choices(ADLB, "PARAMCD", "PARAM"), #' selected = c("ALT", "CRP", "IGA") #' ), #' add_total = FALSE @@ -529,13 +534,13 @@ srv_t_abnormality_by_worst_grade <- function(id, # nolint anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_ancova.R b/R/tm_t_ancova.R index 8d919f36c1..172e4ecd07 100644 --- a/R/tm_t_ancova.R +++ b/R/tm_t_ancova.R @@ -429,8 +429,8 @@ template_ancova <- function(dataname = "ANL", #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adqs <- tmc_ex_adqs +#' ADSL <- tmc_ex_adsl +#' ADQS <- tmc_ex_adqs #' #' arm_ref_comp <- list( #' ARM = list( @@ -445,36 +445,40 @@ template_ancova <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADQS = adqs +#' ADSL = ADSL, +#' ADQS = ADQS, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADQS <- tmc_ex_adqs +#' " #' ), #' modules = modules( #' tm_t_ancova( #' label = "ANCOVA Table", #' dataname = "ADQS", #' avisit = choices_selected( -#' choices = value_choices(adqs, "AVISIT"), +#' choices = value_choices(ADQS, "AVISIT"), #' selected = "WEEK 1 DAY 8" #' ), #' arm_var = choices_selected( -#' choices = variable_choices(adsl, c("ARM", "ACTARMCD", "ARMCD")), +#' choices = variable_choices(ADSL, c("ARM", "ACTARMCD", "ARMCD")), #' selected = "ARMCD" #' ), #' arm_ref_comp = arm_ref_comp, #' aval_var = choices_selected( -#' choices = variable_choices(adqs, c("CHG", "AVAL")), +#' choices = variable_choices(ADQS, c("CHG", "AVAL")), #' selected = "CHG" #' ), #' cov_var = choices_selected( -#' choices = variable_choices(adqs, c("BASE", "STRATA1", "SEX")), +#' choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")), #' selected = "STRATA1" #' ), #' paramcd = choices_selected( -#' choices = value_choices(adqs, "PARAMCD", "PARAM"), +#' choices = value_choices(ADQS, "PARAMCD", "PARAM"), #' selected = "FKSI-FWB" #' ), #' interact_var = choices_selected( -#' choices = variable_choices(adqs, c("BASE", "STRATA1", "SEX")), +#' choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")), #' selected = "STRATA1" #' ) #' ) @@ -726,7 +730,7 @@ srv_ancova <- function(id, anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) @@ -734,7 +738,7 @@ srv_ancova <- function(id, datasets = data, data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) anl_q <- shiny::reactive({ diff --git a/R/tm_t_binary_outcome.R b/R/tm_t_binary_outcome.R index bbbf93088f..15fad4ff25 100644 --- a/R/tm_t_binary_outcome.R +++ b/R/tm_t_binary_outcome.R @@ -393,8 +393,8 @@ template_binary_outcome <- function(dataname, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adrs <- tmc_ex_adrs %>% +#' ADSL <- tmc_ex_adsl +#' ADRS <- tmc_ex_adrs %>% #' dplyr::mutate( #' AVALC = tern::d_onco_rsp_label(AVALC) %>% #' formatters::with_label("Character Result/Finding") @@ -407,24 +407,33 @@ template_binary_outcome <- function(dataname, #' ) #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADRS = adrs +#' ADSL = ADSL, +#' ADRS = ADRS, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADRS <- tmc_ex_adrs %>% +#' dplyr::mutate( +#' AVALC = tern::d_onco_rsp_label(AVALC) %>% +#' formatters::with_label(\"Character Result/Finding\") +#' ) %>% +#' dplyr::filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\") +#' " #' ), #' modules = modules( #' tm_t_binary_outcome( #' label = "Responders", #' dataname = "ADRS", #' paramcd = choices_selected( -#' choices = value_choices(adrs, "PARAMCD", "PARAM"), +#' choices = value_choices(ADRS, "PARAMCD", "PARAM"), #' selected = "BESRSPI" #' ), #' arm_var = choices_selected( -#' choices = variable_choices(adrs, c("ARM", "ARMCD", "ACTARMCD")), +#' choices = variable_choices(ADRS, c("ARM", "ARMCD", "ACTARMCD")), #' selected = "ARM" #' ), #' arm_ref_comp = arm_ref_comp, #' strata_var = choices_selected( -#' choices = variable_choices(adrs, c("SEX", "BMRKR2", "RACE")), +#' choices = variable_choices(ADRS, c("SEX", "BMRKR2", "RACE")), #' select = "RACE" #' ), #' default_responses = list( @@ -783,13 +792,13 @@ srv_t_binary_outcome <- function(id, datasets = data, selector_list = selector_list, merge_function = "dplyr::inner_join", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var, strata_var = strata_var), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_coxreg.R b/R/tm_t_coxreg.R index 14e98fd893..6b7b1c6a71 100644 --- a/R/tm_t_coxreg.R +++ b/R/tm_t_coxreg.R @@ -353,8 +353,6 @@ template_coxreg_m <- function(dataname, #' ## The example below is based on the usual approach involving creation of #' ## a random CDISC dataset and then running the application. #' -#' adsl <- tmc_ex_adsl -#' adtte <- tmc_ex_adtte #' arm_ref_comp <- list( #' ACTARMCD = list( #' ref = "ARM B", @@ -366,11 +364,17 @@ template_coxreg_m <- function(dataname, #' ) #' ) #' +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte +#' }) +#' datanames <- c("ADSL", "ADTTE") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) +#' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADTTE = adtte -#' ), +#' data = data, #' modules = modules( #' tm_t_coxreg( #' label = "Cox Reg.", @@ -378,7 +382,7 @@ template_coxreg_m <- function(dataname, #' arm_var = choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' value_choices(adtte, "PARAMCD", "PARAM"), "OS" +#' value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), "OS" #' ), #' strata_var = choices_selected( #' c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1" @@ -403,32 +407,39 @@ template_coxreg_m <- function(dataname, #' ## Dataset fabrication #' ## ------------------- #' -#' adtte <- data.frame( -#' STUDYID = "LUNG", -#' AVAL = c(4, 3, 1, 1, 2, 2, 3, 1, 2), -#' CNSR = c(1, 1, 1, 0, 1, 1, 0, 0, 0), -#' ARMCD = factor( -#' c(0, 1, 1, 1, 1, 0, 0, 0, 0), -#' labels = c("ARM A", "ARM B") -#' ), -#' SEX = factor( -#' c(0, 0, 0, 0, 1, 1, 1, 1, 1), -#' labels = c("F", "M") -#' ), -#' INST = factor(c("A", "A", "B", "B", "A", "B", "A", "B", "A")), -#' stringsAsFactors = FALSE -#' ) -#' adtte <- base::rbind(adtte, adtte, adtte, adtte) -#' adtte <- dplyr::as_tibble(adtte) -#' set.seed(1) -#' adtte$INST <- sample(adtte$INST) -#' adtte$AGE <- sample(seq(5, 75, 5), size = nrow(adtte), replace = TRUE) -#' adtte$USUBJID <- paste("sub", 1:nrow(adtte), adtte$INST, sep = "-") -#' adtte$PARAM <- adtte$PARAMCD <- "OS" -#' adsl <- subset( -#' adtte, -#' select = c("USUBJID", "STUDYID", "ARMCD", "SEX", "INST", "AGE") -#' ) +#' data <- teal_data() +#' data <- within(data, { +#' ADTTE <- data.frame( +#' STUDYID = "LUNG", +#' AVAL = c(4, 3, 1, 1, 2, 2, 3, 1, 2), +#' CNSR = c(1, 1, 1, 0, 1, 1, 0, 0, 0), +#' ARMCD = factor( +#' c(0, 1, 1, 1, 1, 0, 0, 0, 0), +#' labels = c("ARM A", "ARM B") +#' ), +#' SEX = factor( +#' c(0, 0, 0, 0, 1, 1, 1, 1, 1), +#' labels = c("F", "M") +#' ), +#' INST = factor(c("A", "A", "B", "B", "A", "B", "A", "B", "A")), +#' stringsAsFactors = FALSE +#' ) +#' ADTTE <- base::rbind(ADTTE, ADTTE, ADTTE, ADTTE) +#' ADTTE <- dplyr::as_tibble(ADTTE) +#' set.seed(1) +#' ADTTE$INST <- sample(ADTTE$INST) +#' ADTTE$AGE <- sample(seq(5, 75, 5), size = nrow(ADTTE), replace = TRUE) +#' ADTTE$USUBJID <- paste("sub", 1:nrow(ADTTE), ADTTE$INST, sep = "-") +#' ADTTE$PARAM <- ADTTE$PARAMCD <- "OS" +#' ADSL <- subset( +#' ADTTE, +#' select = c("USUBJID", "STUDYID", "ARMCD", "SEX", "INST", "AGE") +#' ) +#' }) +#' +#' datanames <- c("ADSL", "ADTTE") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' ## Teal application #' ## ================ @@ -438,11 +449,7 @@ template_coxreg_m <- function(dataname, #' #' arm_ref_comp <- list(ARMCD = list(ref = "ARM A", comp = c("ARM B"))) #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADTTE = adtte -#' ) -#' ), +#' data = data, #' modules = modules( #' tm_t_coxreg( #' label = "Cox Reg.", @@ -450,7 +457,7 @@ template_coxreg_m <- function(dataname, #' arm_var = choices_selected(c("ARMCD"), "ARMCD"), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' value_choices(adtte, "PARAMCD", "PARAM"), "OS" +#' value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), "OS" #' ), #' strata_var = choices_selected(c("INST"), NULL), #' cov_var = choices_selected(c("SEX", "AGE"), "SEX"), @@ -783,7 +790,7 @@ srv_t_coxreg <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) diff --git a/R/tm_t_events.R b/R/tm_t_events.R index cd2f86ca94..c97d917609 100644 --- a/R/tm_t_events.R +++ b/R/tm_t_events.R @@ -447,13 +447,17 @@ template_events <- function(dataname, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adae <- tmc_ex_adae +#' ADSL <- tmc_ex_adsl +#' ADAE <- tmc_ex_adae #' #' app <- teal::init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae +#' ADSL = ADSL, +#' ADAE = ADAE, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADAE <- tmc_ex_adae +#' " #' ), #' modules = modules( #' tm_t_events( @@ -461,11 +465,11 @@ template_events <- function(dataname, #' dataname = "ADAE", #' arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), #' llt = choices_selected( -#' choices = variable_choices(adae, c("AETERM", "AEDECOD")), +#' choices = variable_choices(ADAE, c("AETERM", "AEDECOD")), #' selected = c("AEDECOD") #' ), #' hlt = choices_selected( -#' choices = variable_choices(adae, c("AEBODSYS", "AESOC")), +#' choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")), #' selected = "AEBODSYS" #' ), #' add_total = TRUE, @@ -675,7 +679,7 @@ srv_t_events_byterm <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) @@ -684,7 +688,7 @@ srv_t_events_byterm <- function(id, datasets = data, data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL", - join_keys = get_join_keys(data) + join_keys = teal.data::get_join_keys(data) ) anl_q <- shiny::reactive({ diff --git a/R/tm_t_events_by_grade.R b/R/tm_t_events_by_grade.R index cea556202f..405dea497e 100644 --- a/R/tm_t_events_by_grade.R +++ b/R/tm_t_events_by_grade.R @@ -783,32 +783,36 @@ template_events_col_by_grade <- function(dataname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' lbls_adae <- formatters::var_labels(tmc_ex_adae) -#' adae <- tmc_ex_adae %>% -#' dplyr::mutate_if(is.character, as.factor) # be certain of having factors -#' formatters::var_labels(adae) <- lbls_adae +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' lbls_adae <- formatters::var_labels(tmc_ex_adae) +#' ADAE <- tmc_ex_adae %>% +#' dplyr::mutate_if(is.character, as.factor) #' be certain of having factors +#' formatters::var_labels(ADAE) <- lbls_adae +#' }) +#' +#' datanames <- c("ADSL", "ADAE") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae -#' ), +#' data = data, #' modules = modules( #' tm_t_events_by_grade( #' label = "Adverse Events by Grade Table", #' dataname = "ADAE", #' arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), #' llt = choices_selected( -#' choices = variable_choices(adae, c("AETERM", "AEDECOD")), +#' choices = variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")), #' selected = c("AEDECOD") #' ), #' hlt = choices_selected( -#' choices = variable_choices(adae, c("AEBODSYS", "AESOC")), +#' choices = variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")), #' selected = "AEBODSYS" #' ), #' grade = choices_selected( -#' choices = variable_choices(adae, c("AETOXGR", "AESEV")), +#' choices = variable_choices(data[["ADAE"]], c("AETOXGR", "AESEV")), #' selected = "AETOXGR" #' ) #' ) @@ -1042,14 +1046,14 @@ srv_t_events_by_grade <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_events_patyear.R b/R/tm_t_events_patyear.R index 33add65b7c..1d0bc4ed93 100644 --- a/R/tm_t_events_patyear.R +++ b/R/tm_t_events_patyear.R @@ -152,33 +152,40 @@ template_events_patyear <- function(dataname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' adaette <- tmc_ex_adaette %>% +#' ADSL <- tmc_ex_adsl +#' ADAETTE <- tmc_ex_adaette %>% #' dplyr::filter(PARAMCD %in% c("AETTE1", "AETTE2", "AETTE3")) %>% #' dplyr::mutate(is_event = CNSR == 0) %>% #' dplyr::mutate(n_events = as.integer(is_event)) #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADAETTE = adaette +#' ADSL = ADSL, +#' ADAETTE = ADAETTE, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADAETTE <- tmc_ex_adaette %>% +#' dplyr::filter(PARAMCD %in% c(\"AETTE1\", \"AETTE2\", \"AETTE3\")) %>% +#' dplyr::mutate(is_event = CNSR == 0) %>% +#' dplyr::mutate(n_events = as.integer(is_event)) +#' " #' ), #' modules = modules( #' tm_t_events_patyear( #' label = "AE Rate Adjusted for Patient-Years At Risk Table", #' dataname = "ADAETTE", #' arm_var = choices_selected( -#' choices = variable_choices(adsl, c("ARM", "ARMCD")), +#' choices = variable_choices(ADSL, c("ARM", "ARMCD")), #' selected = "ARMCD" #' ), #' add_total = TRUE, #' events_var = choices_selected( -#' choices = variable_choices(adaette, "n_events"), +#' choices = variable_choices(ADAETTE, "n_events"), #' selected = "n_events", #' fixed = TRUE #' ), #' paramcd = choices_selected( -#' choices = value_choices(adaette, "PARAMCD", "PARAM"), +#' choices = value_choices(ADAETTE, "PARAMCD", "PARAM"), #' selected = "AETTE1" #' ) #' ) @@ -436,14 +443,14 @@ srv_events_patyear <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = list(arm_var = arm_var), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_events_summary.R b/R/tm_t_events_summary.R index 0ae66c1306..600a552d40 100644 --- a/R/tm_t_events_summary.R +++ b/R/tm_t_events_summary.R @@ -496,48 +496,53 @@ template_events_summary <- function(anl_name, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl %>% -#' dplyr::mutate( -#' DTHFL = dplyr::case_when( # nolint -#' !is.na(DTHDT) ~ "Y", -#' TRUE ~ "" -#' ) %>% formatters::with_label("Subject Death Flag") -#' ) -#' adae <- tmc_ex_adae -#' -#' add_event_flags <- function(dat) { -#' dat <- dat %>% +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl %>% #' dplyr::mutate( -#' TMPFL_SER = AESER == "Y", -#' TMPFL_REL = AEREL == "Y", -#' TMPFL_GR5 = AETOXGR == "5", -#' TMP_SMQ01 = !is.na(SMQ01NAM), -#' TMP_SMQ02 = !is.na(SMQ02NAM), -#' TMP_CQ01 = !is.na(CQ01NAM) +#' DTHFL = dplyr::case_when( #' nolint +#' !is.na(DTHDT) ~ "Y", +#' TRUE ~ "" +#' ) %>% formatters::with_label("Subject Death Flag") #' ) -#' column_labels <- list( -#' TMPFL_SER = "Serious AE", -#' TMPFL_REL = "Related AE", -#' TMPFL_GR5 = "Grade 5 AE", -#' TMP_SMQ01 = aesi_label(dat[["SMQ01NAM"]], dat[["SMQ01SC"]]), -#' TMP_SMQ02 = aesi_label("Y.9.9.9.9/Z.9.9.9.9 AESI"), -#' TMP_CQ01 = aesi_label(dat[["CQ01NAM"]]) -#' ) -#' formatters::var_labels(dat)[names(column_labels)] <- as.character(column_labels) -#' dat -#' } +#' ADAE <- tmc_ex_adae +#' +#' add_event_flags <- function(dat) { +#' dat <- dat %>% +#' dplyr::mutate( +#' TMPFL_SER = AESER == "Y", +#' TMPFL_REL = AEREL == "Y", +#' TMPFL_GR5 = AETOXGR == "5", +#' TMP_SMQ01 = !is.na(SMQ01NAM), +#' TMP_SMQ02 = !is.na(SMQ02NAM), +#' TMP_CQ01 = !is.na(CQ01NAM) +#' ) +#' column_labels <- list( +#' TMPFL_SER = "Serious AE", +#' TMPFL_REL = "Related AE", +#' TMPFL_GR5 = "Grade 5 AE", +#' TMP_SMQ01 = aesi_label(dat[["SMQ01NAM"]], dat[["SMQ01SC"]]), +#' TMP_SMQ02 = aesi_label("Y.9.9.9.9/Z.9.9.9.9 AESI"), +#' TMP_CQ01 = aesi_label(dat[["CQ01NAM"]]) +#' ) +#' formatters::var_labels(dat)[names(column_labels)] <- as.character(column_labels) +#' dat +#' } +#' +#' #' Generating user-defined event flags. +#' ADAE <- ADAE %>% add_event_flags() +#' +#' ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")] +#' aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")] #' -#' # Generating user-defined event flags. -#' adae <- adae %>% add_event_flags() +#' }) #' -#' ae_anl_vars <- names(adae)[startsWith(names(adae), "TMPFL_")] -#' aesi_vars <- names(adae)[startsWith(names(adae), "TMP_")] +#' datanames <- c("ADSL", "ADAE") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae -#' ), +#' data = data, #' modules = modules( #' tm_t_events_summary( #' label = "Adverse Events Summary", @@ -547,14 +552,14 @@ template_events_summary <- function(anl_name, #' selected = "ARM" #' ), #' flag_var_anl = choices_selected( -#' choices = variable_choices("ADAE", ae_anl_vars), -#' selected = ae_anl_vars[1], +#' choices = variable_choices("ADAE", data[["ae_anl_vars"]]), +#' selected = data[["ae_anl_vars"]][1], #' keep_order = TRUE, #' fixed = FALSE #' ), #' flag_var_aesi = choices_selected( -#' choices = variable_choices("ADAE", aesi_vars), -#' selected = aesi_vars[1], +#' choices = variable_choices("ADAE", data[["aesi_vars"]]), +#' selected = data[["aesi_vars"]][1], #' keep_order = TRUE, #' fixed = FALSE #' ), @@ -820,14 +825,14 @@ srv_t_events_summary <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, data_extract = Filter(Negate(is.null), list(arm_var = arm_var, dthfl_var = dthfl_var, dcsreas_var = dcsreas_var)), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_exposure.R b/R/tm_t_exposure.R index 3d6e071ff8..2e0e391628 100644 --- a/R/tm_t_exposure.R +++ b/R/tm_t_exposure.R @@ -225,45 +225,49 @@ template_exposure <- function(parentname, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adex <- tmc_ex_adex +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' ADEX <- tmc_ex_adex #' -#' set.seed(1, kind = "Mersenne-Twister") -#' labels <- formatters::var_labels(adex, fill = FALSE) -#' adex <- adex %>% -#' dplyr::distinct(USUBJID, .keep_all = TRUE) %>% -#' dplyr::mutate( -#' PARAMCD = "TDURD", -#' PARAM = "Overall duration (days)", -#' AVAL = sample(x = seq(1, 200), size = dplyr::n(), replace = TRUE), -#' AVALU = "Days" -#' ) %>% -#' dplyr::bind_rows(adex) -#' formatters::var_labels(adex) <- labels +#' set.seed(1, kind = "Mersenne-Twister") +#' labels <- formatters::var_labels(ADEX, fill = FALSE) +#' ADEX <- ADEX %>% +#' dplyr::distinct(USUBJID, .keep_all = TRUE) %>% +#' dplyr::mutate( +#' PARAMCD = "TDURD", +#' PARAM = "Overall duration (days)", +#' AVAL = sample(x = seq(1, 200), size = dplyr::n(), replace = TRUE), +#' AVALU = "Days" +#' ) %>% +#' dplyr::bind_rows(ADEX) +#' formatters::var_labels(ADEX) <- labels +#' }) +#' +#' datanames <- c("ADSL", "ADEX") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADEX = adex -#' ), +#' data = data, #' modules = modules( #' tm_t_exposure( #' label = "Duration of Exposure Table", #' dataname = "ADEX", #' paramcd = choices_selected( -#' choices = value_choices(adex, "PARAMCD", "PARAM"), +#' choices = value_choices(data[["ADEX"]], "PARAMCD", "PARAM"), #' selected = "TDURD" #' ), #' col_by_var = choices_selected( -#' choices = variable_choices(adex, subset = c("SEX", "ARM")), +#' choices = variable_choices(data[["ADEX"]], subset = c("SEX", "ARM")), #' selected = "SEX" #' ), #' row_by_var = choices_selected( -#' choices = variable_choices(adex, subset = c("RACE", "REGION1", "STRATA1", "SEX")), +#' choices = variable_choices(data[["ADEX"]], subset = c("RACE", "REGION1", "STRATA1", "SEX")), #' selected = "RACE" #' ), #' parcat = choices_selected( -#' choices = value_choices(adex, "PARCAT2"), +#' choices = value_choices(data[["ADEX"]], "PARCAT2"), #' selected = "Drug A" #' ), #' add_total = FALSE @@ -524,13 +528,13 @@ srv_t_exposure <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(col_by_var = col_by_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_logistic.R b/R/tm_t_logistic.R index 2dee5ce2d3..36bc96b4c0 100644 --- a/R/tm_t_logistic.R +++ b/R/tm_t_logistic.R @@ -228,8 +228,8 @@ template_logistic <- function(dataname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' adrs <- tmc_ex_adrs %>% +#' ADSL <- tmc_ex_adsl +#' ADRS <- tmc_ex_adrs %>% #' dplyr::filter(PARAMCD %in% c("BESRSPI", "INVET")) #' #' arm_ref_comp <- list( @@ -245,20 +245,25 @@ template_logistic <- function(dataname, #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADRS = adrs +#' ADSL = ADSL, +#' ADRS = ADRS, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADRS <- tmc_ex_adrs %>% +#' dplyr::filter(PARAMCD %in% c("BESRSPI", "INVET")) +#' " #' ), #' modules = modules( #' tm_t_logistic( #' label = "Logistic Regression", #' dataname = "ADRS", #' arm_var = choices_selected( -#' choices = variable_choices(adrs, c("ARM", "ARMCD")), +#' choices = variable_choices(ADRS, c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' choices = value_choices(adrs, "PARAMCD", "PARAM"), +#' choices = value_choices(ADRS, "PARAMCD", "PARAM"), #' selected = "BESRSPI" #' ), #' cov_var = choices_selected( @@ -518,13 +523,13 @@ srv_t_logistic <- function(id, anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index 4dd25f3ea8..bf9eed7004 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -280,14 +280,19 @@ template_mult_events <- function(dataname, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adcm <- tmc_ex_adcm +#' ADSL <- tmc_ex_adsl +#' ADCM <- tmc_ex_adcm #' adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") #' #' app <- teal::init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADCM = adcm # TODO use adcm_keys +#' ADSL = ADSL, +#' ADCM = ADCM, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADCM <- tmc_ex_adcm +#' ", +#' join_keys = join_keys #TODO join_key #' ), #' modules = modules( #' tm_t_mult_events( @@ -296,11 +301,11 @@ template_mult_events <- function(dataname, #' arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), #' seq_var = choices_selected("CMSEQ", selected = "CMSEQ", fixed = TRUE), #' hlt = choices_selected( -#' choices = variable_choices(adcm, c("ATC1", "ATC2", "ATC3", "ATC4")), +#' choices = variable_choices(ADCM, c("ATC1", "ATC2", "ATC3", "ATC4")), #' selected = c("ATC1", "ATC2", "ATC3", "ATC4") #' ), #' llt = choices_selected( -#' choices = variable_choices(adcm, c("CMDECOD")), +#' choices = variable_choices(ADCM, c("CMDECOD")), #' selected = c("CMDECOD") #' ), #' add_total = TRUE, @@ -479,7 +484,7 @@ srv_t_mult_events_byterm <- function(id, anl_merge_inputs <- teal.transform::merge_expression_srv( id = "anl_merge", datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) @@ -487,7 +492,7 @@ srv_t_mult_events_byterm <- function(id, adsl_merge_inputs <- teal.transform::merge_expression_module( id = "adsl_merge", datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index 520c55328c..e3232d167b 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -65,11 +65,12 @@ template_basic_info <- function(dataname = "ANL", #' @export #' #' @examples -#' adsl <- tmc_ex_adsl +#' ADSL <- tmc_ex_adsl #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl +#' ADSL = ADSL, +#' code = "ADSL <- tmc_ex_adsl" #' ), #' modules = modules( #' tm_t_pp_basic_info( @@ -77,7 +78,7 @@ template_basic_info <- function(dataname = "ANL", #' dataname = "ADSL", #' patient_col = "USUBJID", #' vars = choices_selected( -#' choices = variable_choices(adsl), +#' choices = variable_choices(ADSL), #' selected = c("ARM", "AGE", "SEX", "COUNTRY", "RACE", "EOSSTT") #' ) #' ) @@ -218,7 +219,7 @@ srv_t_basic_info <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) diff --git a/R/tm_t_pp_laboratory.R b/R/tm_t_pp_laboratory.R index fd1a16b1bc..989a726fc3 100644 --- a/R/tm_t_pp_laboratory.R +++ b/R/tm_t_pp_laboratory.R @@ -118,13 +118,17 @@ template_laboratory <- function(dataname = "ANL", #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb +#' " #' ), #' modules = modules( #' tm_t_pp_laboratory( @@ -132,27 +136,27 @@ template_laboratory <- function(dataname = "ANL", #' dataname = "ADLB", #' patient_col = "USUBJID", #' paramcd = choices_selected( -#' choices = variable_choices(adlb, "PARAMCD"), +#' choices = variable_choices(ADLB, "PARAMCD"), #' selected = "PARAMCD" #' ), #' param = choices_selected( -#' choices = variable_choices(adlb, "PARAM"), +#' choices = variable_choices(ADLB, "PARAM"), #' selected = "PARAM" #' ), #' timepoints = choices_selected( -#' choices = variable_choices(adlb, "ADY"), +#' choices = variable_choices(ADLB, "ADY"), #' selected = "ADY" #' ), #' anrind = choices_selected( -#' choices = variable_choices(adlb, "ANRIND"), +#' choices = variable_choices(ADLB, "ANRIND"), #' selected = "ANRIND" #' ), #' aval = choices_selected( -#' choices = variable_choices(adlb, "AVAL"), +#' choices = variable_choices(ADLB, "AVAL"), #' selected = "AVAL" #' ), #' avalu = choices_selected( -#' choices = variable_choices(adlb, "AVALU"), +#' choices = variable_choices(ADLB, "AVALU"), #' selected = "AVALU" #' ) #' ) @@ -377,7 +381,7 @@ srv_g_laboratory <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list ) diff --git a/R/tm_t_pp_medical_history.R b/R/tm_t_pp_medical_history.R index d3a92a7195..8c57b5402d 100644 --- a/R/tm_t_pp_medical_history.R +++ b/R/tm_t_pp_medical_history.R @@ -89,13 +89,17 @@ template_medical_history <- function(dataname = "ANL", #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' admh <- tmc_ex_admh +#' ADSL <- tmc_ex_adsl +#' ADMH <- tmc_ex_admh #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADMH = admh +#' ADSL = ADSL, +#' ADMH = ADMH, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADMH <- tmc_ex_admh +#' " #' ), #' modules = modules( #' tm_t_pp_medical_history( @@ -104,15 +108,15 @@ template_medical_history <- function(dataname = "ANL", #' parentname = "ADSL", #' patient_col = "USUBJID", #' mhterm = choices_selected( -#' choices = variable_choices(admh, c("MHTERM")), +#' choices = variable_choices(ADMH, c("MHTERM")), #' selected = "MHTERM" #' ), #' mhbodsys = choices_selected( -#' choices = variable_choices(admh, "MHBODSYS"), +#' choices = variable_choices(ADMH, "MHBODSYS"), #' selected = "MHBODSYS" #' ), #' mhdistat = choices_selected( -#' choices = variable_choices(admh, "MHDISTAT"), +#' choices = variable_choices(ADMH, "MHDISTAT"), #' selected = "MHDISTAT" #' ) #' ) @@ -278,7 +282,7 @@ srv_t_medical_history <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::left_join" ) diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index 60987c6385..7760eb8aff 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -72,16 +72,23 @@ template_prior_medication <- function(dataname = "ANL", #' @export #' #' @examples -#' adcm <- tmc_ex_adcm -#' adsl <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% adcm$USUBJID) -#' adcm$CMASTDTM <- adcm$ASTDTM -#' adcm$CMAENDTM <- adcm$AENDTM +#' ADCM <- tmc_ex_adcm +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADCM$USUBJID) +#' ADCM$CMASTDTM <- ADCM$ASTDTM +#' ADCM$CMAENDTM <- ADCM$AENDTM #' adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADCM = adcm +#' ADSL = ADSL, +#' ADCM = ADCM, +#' code = " +#' ADCM <- tmc_ex_adcm +#' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADCM$USUBJID) +#' ADCM$CMASTDTM <- ADCM$ASTDTM +#' ADCM$CMAENDTM <- ADCM$AENDTM +#' ", +#' join_keys = join_keys #TODO Join- key #' ), #' modules = modules( #' tm_t_pp_prior_medication( @@ -90,19 +97,19 @@ template_prior_medication <- function(dataname = "ANL", #' parentname = "ADSL", #' patient_col = "USUBJID", #' atirel = choices_selected( -#' choices = variable_choices(adcm, "ATIREL"), +#' choices = variable_choices(ADCM, "ATIREL"), #' selected = "ATIREL" #' ), #' cmdecod = choices_selected( -#' choices = variable_choices(adcm, "CMDECOD"), +#' choices = variable_choices(ADCM, "CMDECOD"), #' selected = "CMDECOD" #' ), #' cmindc = choices_selected( -#' choices = variable_choices(adcm, "CMINDC"), +#' choices = variable_choices(ADCM, "CMINDC"), #' selected = "CMINDC" #' ), #' cmstdy = choices_selected( -#' choices = variable_choices(adcm, "ASTDY"), +#' choices = variable_choices(ADCM, "ASTDY"), #' selected = "ASTDY" #' ) #' ) @@ -287,7 +294,7 @@ srv_t_prior_medication <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::left_join" ) diff --git a/R/tm_t_shift_by_arm.R b/R/tm_t_shift_by_arm.R index 24216ca671..2586b31f6e 100644 --- a/R/tm_t_shift_by_arm.R +++ b/R/tm_t_shift_by_arm.R @@ -168,36 +168,40 @@ template_shift_by_arm <- function(dataname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' adeg <- tmc_ex_adeg +#' ADSL <- tmc_ex_adsl +#' ADEG <- tmc_ex_adeg #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADEG = adeg +#' ADSL = ADSL, +#' ADEG = ADEG, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADEG <- tmc_ex_adeg +#' " #' ), #' modules = modules( #' tm_t_shift_by_arm( #' label = "Shift by Arm Table", #' dataname = "ADEG", #' arm_var = choices_selected( -#' variable_choices(adsl, subset = c("ARM", "ARMCD")), +#' variable_choices(ADSL, subset = c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' paramcd = choices_selected( -#' value_choices(adeg, "PARAMCD"), +#' value_choices(ADEG, "PARAMCD"), #' selected = "HR" #' ), #' visit_var = choices_selected( -#' value_choices(adeg, "AVISIT"), +#' value_choices(ADEG, "AVISIT"), #' selected = "POST-BASELINE MINIMUM" #' ), #' aval_var = choices_selected( -#' variable_choices(adeg, subset = "ANRIND"), +#' variable_choices(ADEG, subset = "ANRIND"), #' selected = "ANRIND", fixed = TRUE #' ), #' base_var = choices_selected( -#' variable_choices(adeg, subset = "BNRIND"), +#' variable_choices(ADEG, subset = "BNRIND"), #' selected = "BNRIND", fixed = TRUE #' ), #' useNA = "ifany" @@ -426,14 +430,14 @@ srv_shift_by_arm <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_shift_by_arm_by_worst.R b/R/tm_t_shift_by_arm_by_worst.R index 7f1c1b562d..a6fe6b1f6e 100644 --- a/R/tm_t_shift_by_arm_by_worst.R +++ b/R/tm_t_shift_by_arm_by_worst.R @@ -176,40 +176,44 @@ template_shift_by_arm_by_worst <- function(dataname, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adeg <- tmc_ex_adeg +#' ADSL <- tmc_ex_adsl +#' ADEG <- tmc_ex_adeg #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADEG = adeg +#' ADSL = ADSL, +#' ADEG = ADEG, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADEG <- tmc_ex_adeg +#' " #' ), #' modules = modules( #' tm_t_shift_by_arm_by_worst( #' label = "Shift by Arm Table", #' dataname = "ADEG", #' arm_var = choices_selected( -#' variable_choices(adsl, subset = c("ARM", "ARMCD")), +#' variable_choices(ADSL, subset = c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' paramcd = choices_selected( -#' value_choices(adeg, "PARAMCD"), +#' value_choices(ADEG, "PARAMCD"), #' selected = "ECGINTP" #' ), #' worst_flag_var = choices_selected( -#' variable_choices(adeg, c("WORS02FL", "WORS01FL")), +#' variable_choices(ADEG, c("WORS02FL", "WORS01FL")), #' selected = "WORS02FL" #' ), #' worst_flag = choices_selected( -#' value_choices(adeg, "WORS02FL"), +#' value_choices(ADEG, "WORS02FL"), #' selected = "Y", fixed = TRUE #' ), #' aval_var = choices_selected( -#' variable_choices(adeg, c("AVALC", "ANRIND")), +#' variable_choices(ADEG, c("AVALC", "ANRIND")), #' selected = "AVALC" #' ), #' base_var = choices_selected( -#' variable_choices(adeg, c("BASEC", "BNRIND")), +#' variable_choices(ADEG, c("BASEC", "BNRIND")), #' selected = "BASEC" #' ), #' useNA = "ifany" @@ -450,13 +454,13 @@ srv_shift_by_arm_by_worst <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_shift_by_grade.R b/R/tm_t_shift_by_grade.R index 30b41724b0..93388139fb 100644 --- a/R/tm_t_shift_by_grade.R +++ b/R/tm_t_shift_by_grade.R @@ -478,41 +478,45 @@ template_shift_by_grade <- function(parentname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb +#' " #' ), #' modules = modules( #' tm_t_shift_by_grade( #' label = "Grade Laboratory Abnormality Table", #' dataname = "ADLB", #' arm_var = choices_selected( -#' choices = variable_choices(adsl, subset = c("ARM", "ARMCD")), +#' choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' paramcd = choices_selected( -#' choices = value_choices(adlb, "PARAMCD", "PARAM"), +#' choices = value_choices(ADLB, "PARAMCD", "PARAM"), #' selected = "ALT" #' ), #' worst_flag_var = choices_selected( -#' choices = variable_choices(adlb, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), +#' choices = variable_choices(ADLB, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), #' selected = c("WGRLOVFL") #' ), #' worst_flag_indicator = choices_selected( -#' value_choices(adlb, "WGRLOVFL"), +#' value_choices(ADLB, "WGRLOVFL"), #' selected = "Y", fixed = TRUE #' ), #' anl_toxgrade_var = choices_selected( -#' choices = variable_choices(adlb, subset = c("ATOXGR")), +#' choices = variable_choices(ADLB, subset = c("ATOXGR")), #' selected = c("ATOXGR"), #' fixed = TRUE #' ), #' base_toxgrade_var = choices_selected( -#' choices = variable_choices(adlb, subset = c("BTOXGR")), +#' choices = variable_choices(ADLB, subset = c("BTOXGR")), #' selected = c("BTOXGR"), #' fixed = TRUE #' ), @@ -786,14 +790,14 @@ srv_t_shift_by_grade <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), selector_list = selector_list, merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_smq.R b/R/tm_t_smq.R index 289e8f63ec..9f862e9bc8 100644 --- a/R/tm_t_smq.R +++ b/R/tm_t_smq.R @@ -318,41 +318,45 @@ template_smq <- function(dataname, #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adae <- tmc_ex_adae +#' data <- teal_data() +#' data <- within(data, { +#' ADSL <- tmc_ex_adsl +#' ADAE <- tmc_ex_adae #' -#' 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 = variable_choices(adae, subset = names_baskets), -#' selected = names_baskets -#' ) +#' cs_baskets <- choices_selected( +#' choices = variable_choices(ADAE, subset = names_baskets), +#' selected = names_baskets +#' ) #' -#' cs_scopes <- choices_selected( -#' choices = variable_choices(adae, subset = names_scopes), -#' selected = names_scopes, -#' fixed = TRUE -#' ) +#' cs_scopes <- choices_selected( +#' choices = variable_choices(ADAE, subset = names_scopes), +#' selected = names_scopes, +#' fixed = TRUE +#' ) +#' }) +#' +#' datanames <- c("ADSL", "ADAE") +#' datanames(data) <- datanames +#' data@join_keys <- cdisc_join_keys(!!!datanames) #' #' app <- init( -#' data = cdisc_data( -#' ADSL = adsl, -#' ADAE = adae -#' ), +#' data = data, #' modules = modules( #' tm_t_smq( #' label = "Adverse Events by SMQ Table", #' dataname = "ADAE", #' arm_var = choices_selected( -#' choices = variable_choices(adsl, subset = c("ARM", "SEX")), +#' choices = variable_choices(data[["ADSL"]], subset = c("ARM", "SEX")), #' selected = "ARM" #' ), #' add_total = FALSE, -#' baskets = cs_baskets, -#' scopes = cs_scopes, +#' baskets = data[["cs_baskets"]], +#' scopes = data[["cs_scopes"]], #' llt = choices_selected( -#' choices = variable_choices(adae, subset = c("AEDECOD")), +#' choices = variable_choices(data[["ADAE"]], subset = c("AEDECOD")), #' selected = "AEDECOD" #' ) #' ) @@ -566,13 +570,13 @@ srv_t_smq <- function(id, anl_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_summary.R b/R/tm_t_summary.R index b9dc250c94..ab2ef229cc 100644 --- a/R/tm_t_summary.R +++ b/R/tm_t_summary.R @@ -225,18 +225,26 @@ template_summary <- function(dataname, #' @export #' @examples #' # Preparation of the test case -#' adsl <- tmc_ex_adsl -#' adsl$EOSDY[1] <- NA_integer_ +#' ADSL <- tmc_ex_adsl +#' ADSL$EOSDY[1] <- NA_integer_ #' #' # Include `EOSDY` and `DCSREAS` variables below because they contain missing data. #' stopifnot( -#' any(is.na(adsl$EOSDY)), -#' any(is.na(adsl$DCSREAS)) +#' any(is.na(ADSL$EOSDY)), +#' any(is.na(ADSL$DCSREAS)) #' ) #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl +#' ADSL = ADSL, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADSL$EOSDY[1] <- NA_integer_ +#' stopifnot( +#' any(is.na(ADSL$EOSDY)), +#' any(is.na(ADSL$DCSREAS)) +#' ) +#' " #' ), #' modules = modules( #' tm_t_summary( @@ -446,7 +454,7 @@ srv_summary <- function(id, id = "anl_merge", datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) @@ -454,7 +462,7 @@ srv_summary <- function(id, id = "adsl_merge", datasets = data, data_extract = list(arm_var = arm_var), - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_summary_by.R b/R/tm_t_summary_by.R index 0ca1b12447..51ff1b6b41 100644 --- a/R/tm_t_summary_by.R +++ b/R/tm_t_summary_by.R @@ -331,34 +331,38 @@ template_summary_by <- function(parentname, #' #' @export #' @examples -#' adsl <- tmc_ex_adsl -#' adlb <- tmc_ex_adlb +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADLB = adlb +#' ADSL = ADSL, +#' ADLB = ADLB, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADLB <- tmc_ex_adlb +#' " #' ), #' modules = modules( #' tm_t_summary_by( #' label = "Summary by Row Groups Table", #' dataname = "ADLB", #' arm_var = choices_selected( -#' choices = variable_choices(adsl, c("ARM", "ARMCD")), +#' choices = variable_choices(ADSL, c("ARM", "ARMCD")), #' selected = "ARM" #' ), #' add_total = TRUE, #' by_vars = choices_selected( -#' choices = variable_choices(adlb, c("PARAM", "AVISIT")), +#' choices = variable_choices(ADLB, c("PARAM", "AVISIT")), #' selected = c("AVISIT") #' ), #' summarize_vars = choices_selected( -#' choices = variable_choices(adlb, c("AVAL", "CHG")), +#' choices = variable_choices(ADLB, c("AVAL", "CHG")), #' selected = c("AVAL") #' ), #' useNA = "ifany", #' paramcd = choices_selected( -#' choices = value_choices(adlb, "PARAMCD", "PARAM"), +#' choices = value_choices(ADLB, "PARAMCD", "PARAM"), #' selected = "ALT" #' ) #' ) @@ -626,14 +630,14 @@ srv_summary_by <- function(id, anl_inputs <- teal.transform::merge_expression_srv( selector_list = selector_list, datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_inputs <- teal.transform::merge_expression_module( id = "adsl_merge", datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var), anl_name = "ANL_ADSL" ) diff --git a/R/tm_t_tte.R b/R/tm_t_tte.R index 6535b570fa..7b04542ec8 100644 --- a/R/tm_t_tte.R +++ b/R/tm_t_tte.R @@ -383,8 +383,8 @@ template_tte <- function(dataname = "ANL", #' @export #' #' @examples -#' adsl <- tmc_ex_adsl -#' adtte <- tmc_ex_adtte +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte #' #' arm_ref_comp <- list( #' ACTARMCD = list( @@ -399,29 +399,33 @@ template_tte <- function(dataname = "ANL", #' #' app <- init( #' data = cdisc_data( -#' ADSL = adsl, -#' ADTTE = adtte +#' ADSL = ADSL, +#' ADTTE = ADTTE, +#' code = " +#' ADSL <- tmc_ex_adsl +#' ADTTE <- tmc_ex_adtte +#' " #' ), #' modules = modules( #' tm_t_tte( #' label = "Time To Event Table", #' dataname = "ADTTE", #' arm_var = choices_selected( -#' variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")), +#' variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), #' "ARM" #' ), #' arm_ref_comp = arm_ref_comp, #' paramcd = choices_selected( -#' value_choices(adtte, "PARAMCD", "PARAM"), +#' value_choices(ADTTE, "PARAMCD", "PARAM"), #' "OS" #' ), #' strata_var = choices_selected( -#' variable_choices(adsl, c("SEX", "BMRKR2")), +#' variable_choices(ADSL, c("SEX", "BMRKR2")), #' "SEX" #' ), #' time_points = choices_selected(c(182, 243), 182), #' event_desc_var = choices_selected( -#' variable_choices(adtte, "EVNTDESC"), +#' variable_choices(ADTTE, "EVNTDESC"), #' "EVNTDESC", #' fixed = TRUE #' ) @@ -792,13 +796,13 @@ srv_t_tte <- function(id, anl_merge_inputs <- teal.transform::merge_expression_srv( datasets = data, selector_list = selector_list, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), merge_function = "dplyr::inner_join" ) adsl_merge_inputs <- teal.transform::merge_expression_module( datasets = data, - join_keys = get_join_keys(data), + join_keys = teal.data::get_join_keys(data), data_extract = list(arm_var = arm_var, strata_var = strata_var), anl_name = "ANL_ADSL" ) diff --git a/man/tm_a_gee.Rd b/man/tm_a_gee.Rd index 01cac27aee..bc11ecd355 100644 --- a/man/tm_a_gee.Rd +++ b/man/tm_a_gee.Rd @@ -89,24 +89,27 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Teal module for Generalized Estimating Equations (GEE) analysis } \examples{ -adsl <- tmc_ex_adsl -adqs <- tmc_ex_adqs \%>\% - dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") \%>\% - dplyr::mutate( - AVISIT = as.factor(AVISIT), - AVISITN = rank(AVISITN) \%>\% - as.factor() \%>\% - as.numeric() \%>\% - as.factor(), - AVALBIN = AVAL < 50 # Just as an example to get a binary endpoint. - ) \%>\% - droplevels() +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + ADQS <- tmc_ex_adqs \%>\% + dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") \%>\% + dplyr::mutate( + AVISIT = as.factor(AVISIT), + AVISITN = rank(AVISITN) \%>\% + as.factor() \%>\% + as.numeric() \%>\% + as.factor(), + AVALBIN = AVAL < 50 #' Just as an example to get a binary endpoint. + ) \%>\% + droplevels() +}) +datanames <- c("ADSL", "ADQS") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADQS = adqs - ), + data = data, modules = modules( tm_a_gee( label = "GEE", @@ -116,7 +119,7 @@ app <- init( arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"), paramcd = choices_selected( - choices = value_choices(adqs, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), selected = "FKSI-FWB" ), cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL) diff --git a/man/tm_a_mmrm.Rd b/man/tm_a_mmrm.Rd index ada3112294..e89b816fdd 100644 --- a/man/tm_a_mmrm.Rd +++ b/man/tm_a_mmrm.Rd @@ -124,18 +124,6 @@ different convergence behavior. This is a known observation with the used packag numerical precision. } \examples{ -adsl <- tmc_ex_adsl -adqs <- tmc_ex_adqs \%>\% - dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") \%>\% - dplyr::filter(AVISIT \%in\% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) \%>\% - dplyr::mutate( - AVISIT = as.factor(AVISIT), - AVISITN = rank(AVISITN) \%>\% - as.factor() \%>\% - as.numeric() \%>\% - as.factor() # making consecutive numeric factor - ) - arm_ref_comp <- list( ARMCD = list( ref = "ARM B", @@ -143,11 +131,26 @@ arm_ref_comp <- list( ) ) +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + ADQS <- tmc_ex_adqs \%>\% + dplyr::filter(ABLFL != "Y" & ABLFL2 != "Y") \%>\% + dplyr::filter(AVISIT \%in\% c("WEEK 1 DAY 8", "WEEK 2 DAY 15", "WEEK 3 DAY 22")) \%>\% + dplyr::mutate( + AVISIT = as.factor(AVISIT), + AVISITN = rank(AVISITN) \%>\% + as.factor() \%>\% + as.numeric() \%>\% + as.factor() #' making consecutive numeric factor + ) +}) + +datanames <- c("ADSL", "ADQS") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADQS = adqs - ), + data = data, modules = modules( tm_a_mmrm( label = "MMRM", @@ -158,7 +161,7 @@ app <- init( visit_var = choices_selected(c("AVISIT", "AVISITN"), "AVISIT"), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - choices = value_choices(adqs, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADQS"]], "PARAMCD", "PARAM"), selected = "FKSI-FWB" ), cov_var = choices_selected(c("BASE", "AGE", "SEX", "BASE:AVISIT"), NULL) diff --git a/man/tm_g_barchart_simple.Rd b/man/tm_g_barchart_simple.Rd index d63953c2d3..1762723b01 100644 --- a/man/tm_g_barchart_simple.Rd +++ b/man/tm_g_barchart_simple.Rd @@ -65,14 +65,17 @@ it is ignored. \examples{ library(nestcolor) -adsl <- tmc_ex_adsl \%>\% dplyr::mutate(ITTFL = factor("Y") \%>\% +ADSL <- tmc_ex_adsl \%>\% dplyr::mutate(ITTFL = factor("Y") \%>\% formatters::with_label("Intent-To-Treat Population Flag")) -adae <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) +ADAE <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) app <- init( data = cdisc_data( - ADSL = adsl, - ADAE = adae + ADSL = ADSL, + ADAE = ADAE, + code = "ADSL <- tmc_ex_adsl \%>\% dplyr::mutate(ITTFL = factor(\"Y\") \%>\% + formatters::with_label(\"Intent-To-Treat Population Flag\")) + ADAE <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))" ), modules = modules( tm_g_barchart_simple( @@ -81,7 +84,7 @@ app <- init( dataname = "ADSL", select = select_spec( choices = variable_choices( - adsl, + ADSL, c( "ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -96,7 +99,7 @@ app <- init( dataname = "ADSL", select = select_spec( choices = variable_choices( - adsl, + ADSL, c( "ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -109,7 +112,7 @@ app <- init( data_extract_spec( dataname = "ADAE", select = select_spec( - choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")), + choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")), selected = NULL, multiple = FALSE ) @@ -119,7 +122,7 @@ app <- init( data_extract_spec( dataname = "ADAE", select = select_spec( - choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")), + choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")), selected = "AETOXGR", multiple = FALSE ) @@ -128,7 +131,7 @@ app <- init( dataname = "ADSL", select = select_spec( choices = variable_choices( - adsl, + ADSL, c( "ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2" @@ -143,7 +146,7 @@ app <- init( data_extract_spec( dataname = "ADAE", select = select_spec( - choices = variable_choices(adae, c("AETOXGR", "AESEV", "AESER")), + choices = variable_choices(ADAE, c("AETOXGR", "AESEV", "AESER")), selected = "AESEV", multiple = FALSE ) @@ -152,7 +155,7 @@ app <- init( dataname = "ADSL", select = select_spec( choices = variable_choices( - adsl, + ADSL, c( "ARM", "ACTARM", "SEX", "RACE", "ITTFL", "SAFFL", "STRATA2" diff --git a/man/tm_g_ci.Rd b/man/tm_g_ci.Rd index a43baace6a..021e092d73 100644 --- a/man/tm_g_ci.Rd +++ b/man/tm_g_ci.Rd @@ -67,13 +67,17 @@ The module generates the R code and returns the corresponding output. \examples{ library(nestcolor) -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb +ADSL <- tmc_ex_adsl +ADLB <- tmc_ex_adlb app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb + " ), modules = modules( tm_g_ci( @@ -92,15 +96,15 @@ app <- init( filter = list( filter_spec( vars = "PARAMCD", - choices = levels(adlb$PARAMCD), - selected = levels(adlb$PARAMCD)[1], + choices = levels(ADLB$PARAMCD), + selected = levels(ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(adlb$AVISIT), - selected = levels(adlb$AVISIT)[1], + choices = levels(ADLB$AVISIT), + selected = levels(ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) diff --git a/man/tm_g_forest_rsp.Rd b/man/tm_g_forest_rsp.Rd index 44a656e38e..805fa239c7 100644 --- a/man/tm_g_forest_rsp.Rd +++ b/man/tm_g_forest_rsp.Rd @@ -114,8 +114,8 @@ This teal module produces a grid style Forest plot for response data with \code{ \examples{ library(nestcolor) -adsl <- tmc_ex_adsl -adrs <- tmc_ex_adrs \%>\% +ADSL <- tmc_ex_adsl +ADRS <- tmc_ex_adrs \%>\% dplyr::mutate(AVALC = tern::d_onco_rsp_label(AVALC) \%>\% formatters::with_label("Character Result/Finding")) \%>\% dplyr::filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP") @@ -133,28 +133,35 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - ADSL = adsl, - ADRS = adrs + ADSL = ADSL, + ADRS = ADRS, + code = " + ADSL <- tmc_ex_adsl + ADRS <- tmc_ex_adrs \%>\% + dplyr::mutate(AVALC = tern::d_onco_rsp_label(AVALC) \%>\% + formatters::with_label(\"Character Result/Finding\")) \%>\% + dplyr::filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\") + " ), modules = modules( tm_g_forest_rsp( label = "Forest Response", dataname = "ADRS", arm_var = choices_selected( - variable_choices(adsl, c("ARM", "ARMCD")), + variable_choices(ADSL, c("ARM", "ARMCD")), "ARMCD" ), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - value_choices(adrs, "PARAMCD", "PARAM"), + value_choices(ADRS, "PARAMCD", "PARAM"), "INVET" ), subgroup_var = choices_selected( - variable_choices(adsl, names(adsl)), + variable_choices(ADSL, names(ADSL)), c("BMRKR2", "SEX") ), strata_var = choices_selected( - variable_choices(adsl, c("STRATA1", "STRATA2")), + variable_choices(ADSL, c("STRATA1", "STRATA2")), "STRATA2" ), plot_height = c(600L, 200L, 2000L), diff --git a/man/tm_g_forest_tte.Rd b/man/tm_g_forest_tte.Rd index 35dbdfbade..8d6b408dba 100644 --- a/man/tm_g_forest_tte.Rd +++ b/man/tm_g_forest_tte.Rd @@ -119,9 +119,9 @@ with \code{ADaM} structure \examples{ library(nestcolor) -adsl <- tmc_ex_adsl -adtte <- tmc_ex_adtte -adsl$RACE <- droplevels(adsl$RACE) \%>\% formatters::with_label("Race") +ADSL <- tmc_ex_adsl +ADTTE <- tmc_ex_adtte +ADSL$RACE <- droplevels(ADSL$RACE) \%>\% formatters::with_label("Race") arm_ref_comp <- list( ARM = list( @@ -136,28 +136,33 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - ADSL = adsl, - ADTTE = adtte + ADSL = ADSL, + ADTTE = ADTTE, + code = " + ADSL <- tmc_ex_adsl + ADTTE <- tmc_ex_adtte + ADSL$RACE <- droplevels(ADSL$RACE) \%>\% formatters::with_label(\"Race\") + " ), modules = modules( tm_g_forest_tte( label = "Forest Survival", dataname = "ADTTE", arm_var = choices_selected( - variable_choices(adsl, c("ARM", "ARMCD")), + variable_choices(ADSL, c("ARM", "ARMCD")), "ARMCD" ), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - value_choices(adtte, "PARAMCD", "PARAM"), + value_choices(ADTTE, "PARAMCD", "PARAM"), "OS" ), subgroup_var = choices_selected( - variable_choices(adsl, names(adsl)), + variable_choices(ADSL, names(ADSL)), c("BMRKR2", "SEX") ), strata_var = choices_selected( - variable_choices(adsl, c("STRATA1", "STRATA2")), + variable_choices(ADSL, c("STRATA1", "STRATA2")), "STRATA2" ), plot_height = c(600, 200, 2000) diff --git a/man/tm_g_ipp.Rd b/man/tm_g_ipp.Rd index 12cfaf1671..4ab0792cfe 100644 --- a/man/tm_g_ipp.Rd +++ b/man/tm_g_ipp.Rd @@ -108,49 +108,52 @@ trends in parameter values over time for each patient using data with \examples{ library(nestcolor) -adsl <- tmc_ex_adsl \%>\% dplyr::slice(1:20) -adlb <- tmc_ex_adlb \%>\% dplyr::filter(USUBJID \%in\% adsl$USUBJID) - -adsl <- df_explicit_na(adsl) -adlb <- df_explicit_na(adlb) \%>\% dplyr::filter(AVISIT != "SCREENING") +ADSL <- tmc_ex_adsl \%>\% dplyr::slice(1:20) \%>\% df_explicit_na() +ADLB <- tmc_ex_adlb \%>\% dplyr::filter(USUBJID \%in\% ADSL$USUBJID) \%>\% + df_explicit_na() \%>\% dplyr::filter(AVISIT != "SCREENING") app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl \%>\% dplyr::slice(1:20) \%>\% df_explicit_na() + ADLB <- tmc_ex_adlb \%>\% dplyr::filter(USUBJID \%in\% ADSL$USUBJID) \%>\% + df_explicit_na() \%>\% dplyr::filter(AVISIT != \"SCREENING\") + " ), modules = modules( tm_g_ipp( label = "Individual Patient Plot", dataname = "ADLB", arm_var = choices_selected( - value_choices(adlb, "ARMCD"), + value_choices(ADLB, "ARMCD"), "ARM A" ), paramcd = choices_selected( - value_choices(adlb, "PARAMCD"), + value_choices(ADLB, "PARAMCD"), "ALT" ), aval_var = choices_selected( - variable_choices(adlb, c("AVAL", "CHG")), + variable_choices(ADLB, c("AVAL", "CHG")), "AVAL" ), avalu_var = choices_selected( - variable_choices(adlb, c("AVALU")), + variable_choices(ADLB, c("AVALU")), "AVALU", fixed = TRUE ), id_var = choices_selected( - variable_choices(adlb, c("USUBJID")), + variable_choices(ADLB, c("USUBJID")), "USUBJID", fixed = TRUE ), visit_var = choices_selected( - variable_choices(adlb, c("AVISIT")), + variable_choices(ADLB, c("AVISIT")), "AVISIT" ), base_var = choices_selected( - variable_choices(adlb, c("BASE")), + variable_choices(ADLB, c("BASE")), "BASE", fixed = TRUE ), diff --git a/man/tm_g_km.Rd b/man/tm_g_km.Rd index 2c76589090..5a4b82a31f 100644 --- a/man/tm_g_km.Rd +++ b/man/tm_g_km.Rd @@ -104,8 +104,8 @@ This teal module produces a grid style \code{Kaplan-Meier} plot for data with \examples{ library(nestcolor) -adsl <- tmc_ex_adsl -adtte <- tmc_ex_adtte +ADSL <- tmc_ex_adsl +ADTTE <- tmc_ex_adtte arm_ref_comp <- list( ACTARMCD = list( @@ -120,28 +120,32 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - ADSL = adsl, - ADTTE = adtte + ADSL = ADSL, + ADTTE = ADTTE, + code = " + ADSL <- tmc_ex_adsl + ADTTE <- tmc_ex_adtte + " ), modules = modules( tm_g_km( label = "Kaplan-Meier Plot", dataname = "ADTTE", arm_var = choices_selected( - variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")), + variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), "ARM" ), paramcd = choices_selected( - value_choices(adtte, "PARAMCD", "PARAM"), + value_choices(ADTTE, "PARAMCD", "PARAM"), "OS" ), arm_ref_comp = arm_ref_comp, strata_var = choices_selected( - variable_choices(adsl, c("SEX", "BMRKR2")), + variable_choices(ADSL, c("SEX", "BMRKR2")), "SEX" ), facet_var = choices_selected( - variable_choices(adsl, c("SEX", "BMRKR2")), + variable_choices(ADSL, c("SEX", "BMRKR2")), NULL ) ) diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index f9949e233a..fc51cc68eb 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -119,28 +119,32 @@ This teal module produces a grid style Line Plot for data with \examples{ library(nestcolor) -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb \%>\% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)) +ADSL <- tmc_ex_adsl +ADLB <- tmc_ex_adlb \%>\% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)) app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb \%>\% dplyr::mutate(AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)) + " ), modules = modules( tm_g_lineplot( label = "Line Plot", dataname = "ADLB", strata = choices_selected( - variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")), + variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), "ARM" ), y = choices_selected( - variable_choices(adlb, c("AVAL", "BASE", "CHG", "PCHG")), + variable_choices(ADLB, c("AVAL", "BASE", "CHG", "PCHG")), "AVAL" ), param = choices_selected( - value_choices(adlb, "PARAMCD", "PARAM"), + value_choices(ADLB, "PARAMCD", "PARAM"), "ALT" ) ) diff --git a/man/tm_g_pp_adverse_events.Rd b/man/tm_g_pp_adverse_events.Rd index 236922cdbc..4427193337 100644 --- a/man/tm_g_pp_adverse_events.Rd +++ b/man/tm_g_pp_adverse_events.Rd @@ -90,13 +90,17 @@ This teal module produces a patient profile adverse events table and plot using \examples{ library(nestcolor) -adae <- tmc_ex_adae -adsl <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% adae$USUBJID) +ADAE <- tmc_ex_adae +ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADAE$USUBJID) app <- init( data = cdisc_data( - ADSL = adsl, - ADAE = adae + ADSL = ADSL, + ADAE = ADAE, + code = " + ADAE <- tmc_ex_adae + ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADAE$USUBJID) + " ), modules = modules( tm_g_pp_adverse_events( @@ -106,27 +110,27 @@ app <- init( patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), aeterm = choices_selected( - choices = variable_choices(adae, "AETERM"), + choices = variable_choices(ADAE, "AETERM"), selected = "AETERM" ), tox_grade = choices_selected( - choices = variable_choices(adae, "AETOXGR"), + choices = variable_choices(ADAE, "AETOXGR"), selected = "AETOXGR" ), causality = choices_selected( - choices = variable_choices(adae, "AEREL"), + choices = variable_choices(ADAE, "AEREL"), selected = "AEREL" ), outcome = choices_selected( - choices = variable_choices(adae, "AEOUT"), + choices = variable_choices(ADAE, "AEOUT"), selected = "AEOUT" ), action = choices_selected( - choices = variable_choices(adae, "AEACN"), + choices = variable_choices(ADAE, "AEACN"), selected = "AEACN" ), time = choices_selected( - choices = variable_choices(adae, "ASTDY"), + choices = variable_choices(ADAE, "ASTDY"), selected = "ASTDY" ), decod = NULL diff --git a/man/tm_g_pp_patient_timeline.Rd b/man/tm_g_pp_patient_timeline.Rd index 860205d112..5748a193bb 100644 --- a/man/tm_g_pp_patient_timeline.Rd +++ b/man/tm_g_pp_patient_timeline.Rd @@ -104,30 +104,40 @@ This teal module produces a patient profile timeline plot using \code{ADaM} data \examples{ library(nestcolor) -adae <- tmc_ex_adae -adsl <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% adae$USUBJID) -adcm <- tmc_ex_adcm \%>\% dplyr::mutate( - CMSTDY = dplyr::case_when( - CMCAT == "medcl B" ~ 20, - CMCAT == "medcl C" ~ 150, - TRUE ~ 1 - ) \%>\% formatters::with_label("Study Day of Start of Medication"), - CMENDY = dplyr::case_when( - CMCAT == "medcl B" ~ 700, - CMCAT == "medcl C" ~ 1000, - TRUE ~ 500 - ) \%>\% formatters::with_label("Study Day of End of Medication"), - CMASTDTM = ASTDTM, - CMAENDTM = AENDTM -) adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") +data <- teal_data() +data <- within(data, { + ADAE <- tmc_ex_adae + ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADAE$USUBJID) + ADCM <- tmc_ex_adcm \%>\% dplyr::mutate( + CMSTDY = dplyr::case_when( + CMCAT == "medcl B" ~ 20, + CMCAT == "medcl C" ~ 150, + TRUE ~ 1 + ) \%>\% formatters::with_label("Study Day of Start of Medication"), + CMENDY = dplyr::case_when( + CMCAT == "medcl B" ~ 700, + CMCAT == "medcl C" ~ 1000, + TRUE ~ 500 + ) \%>\% formatters::with_label("Study Day of End of Medication"), + CMASTDTM = ASTDTM, + CMAENDTM = AENDTM + ) +}) + +datanames(data) <- c("ADSL", "ADAE", "ADCM") +data@join_keys <- join_keys( + join_key("ADSL",keys = get_cdisc_keys("ADSL")), + join_key("ADAE", keys = get_cdisc_keys("ADAE")), + join_key("ADCM", keys = adcm_keys), + join_key("ADAE", "ADSL", c("USUBJID", "STUDYID")), + join_key("ADAE", "ADCM", c("USUBJID", "STUDYID")), + join_key("ADCM", "ADSL", c("USUBJID", "STUDYID")), +) + app <- init( - data = cdisc_data( - ADSL = adsl, - ADAE = adae, - ADCM = adcm # TODO use adcm_keys - ), + data = data, modules = modules( tm_g_pp_patient_timeline( label = "Patient Timeline", @@ -137,43 +147,43 @@ app <- init( patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), cmdecod = choices_selected( - choices = variable_choices(adcm, "CMDECOD"), + choices = variable_choices(data[["ADCM"]], "CMDECOD"), selected = "CMDECOD", ), aeterm = choices_selected( - choices = variable_choices(adae, "AETERM"), + choices = variable_choices(data[["ADAE"]], "AETERM"), selected = c("AETERM") ), aetime_start = choices_selected( - choices = variable_choices(adae, "ASTDTM"), + choices = variable_choices(data[["ADAE"]], "ASTDTM"), selected = c("ASTDTM") ), aetime_end = choices_selected( - choices = variable_choices(adae, "AENDTM"), + choices = variable_choices(data[["ADAE"]], "AENDTM"), selected = c("AENDTM") ), dstime_start = choices_selected( - choices = variable_choices(adcm, "CMASTDTM"), + choices = variable_choices(data[["ADCM"]], "CMASTDTM"), selected = c("CMASTDTM") ), dstime_end = choices_selected( - choices = variable_choices(adcm, "CMAENDTM"), + choices = variable_choices(data[["ADCM"]], "CMAENDTM"), selected = c("CMAENDTM") ), aerelday_start = choices_selected( - choices = variable_choices(adae, "ASTDY"), + choices = variable_choices(data[["ADAE"]], "ASTDY"), selected = c("ASTDY") ), aerelday_end = choices_selected( - choices = variable_choices(adae, "AENDY"), + choices = variable_choices(data[["ADAE"]], "AENDY"), selected = c("AENDY") ), dsrelday_start = choices_selected( - choices = variable_choices(adcm, "ASTDY"), + choices = variable_choices(data[["ADCM"]], "ASTDY"), selected = c("ASTDY") ), dsrelday_end = choices_selected( - choices = variable_choices(adcm, "AENDY"), + choices = variable_choices(data[["ADCM"]], "AENDY"), selected = c("AENDY") ) ) diff --git a/man/tm_g_pp_therapy.Rd b/man/tm_g_pp_therapy.Rd index dc28f85132..7fe375ae5a 100644 --- a/man/tm_g_pp_therapy.Rd +++ b/man/tm_g_pp_therapy.Rd @@ -102,16 +102,27 @@ This teal module produces a patient profile therapy plot using \code{ADaM} datas \examples{ library(nestcolor) -adcm <- tmc_ex_adcm -adsl <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% adcm$USUBJID) -adcm$CMASTDTM <- adcm$ASTDTM -adcm$CMAENDTM <- adcm$AENDTM +ADCM <- tmc_ex_adcm +ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADCM$USUBJID) +ADCM$CMASTDTM <- ADCM$ASTDTM +ADCM$CMAENDTM <- ADCM$AENDTM adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") app <- init( data = cdisc_data( - ADSL = adsl, - ADCM = adcm # TODO use adcm_keys + ADSL = ADSL, + ADCM = adcm, + code = " + ADCM <- tmc_ex_adcm + ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADCM$USUBJID) + ADCM$CMASTDTM <- ADCM$ASTDTM + ADCM$CMAENDTM <- ADCM$AENDTM + ", + join_keys = join_keys( + join_key("ADSL", keys = get_cdisc_keys("ADSL")), + join_key("ADCM", keys = adcm_keys), + join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) + ) ), modules = modules( tm_g_pp_therapy( @@ -121,43 +132,43 @@ app <- init( patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), atirel = choices_selected( - choices = variable_choices(adcm, "ATIREL"), + choices = variable_choices(ADCM, "ATIREL"), selected = c("ATIREL") ), cmdecod = choices_selected( - choices = variable_choices(adcm, "CMDECOD"), + choices = variable_choices(ADCM, "CMDECOD"), selected = "CMDECOD" ), cmindc = choices_selected( - choices = variable_choices(adcm, "CMINDC"), + choices = variable_choices(ADCM, "CMINDC"), selected = "CMINDC" ), cmdose = choices_selected( - choices = variable_choices(adcm, "CMDOSE"), + choices = variable_choices(ADCM, "CMDOSE"), selected = "CMDOSE" ), cmtrt = choices_selected( - choices = variable_choices(adcm, "CMTRT"), + choices = variable_choices(ADCM, "CMTRT"), selected = "CMTRT" ), cmdosu = choices_selected( - choices = variable_choices(adcm, "CMDOSU"), + choices = variable_choices(ADCM, "CMDOSU"), selected = c("CMDOSU") ), cmroute = choices_selected( - choices = variable_choices(adcm, "CMROUTE"), + choices = variable_choices(ADCM, "CMROUTE"), selected = "CMROUTE" ), cmdosfrq = choices_selected( - choices = variable_choices(adcm, "CMDOSFRQ"), + choices = variable_choices(ADCM, "CMDOSFRQ"), selected = "CMDOSFRQ" ), cmstdy = choices_selected( - choices = variable_choices(adcm, "ASTDY"), + choices = variable_choices(ADCM, "ASTDY"), selected = "ASTDY" ), cmendy = choices_selected( - choices = variable_choices(adcm, "AENDY"), + choices = variable_choices(ADCM, "AENDY"), selected = "AENDY" ) ) diff --git a/man/tm_g_pp_vitals.Rd b/man/tm_g_pp_vitals.Rd index dbe6f55c1a..3736addbc3 100644 --- a/man/tm_g_pp_vitals.Rd +++ b/man/tm_g_pp_vitals.Rd @@ -74,13 +74,17 @@ This teal module produces a patient profile vitals plot using \code{ADaM} datase \examples{ library(nestcolor) -adsl <- tmc_ex_adsl -advs <- tmc_ex_advs +ADSL <- tmc_ex_adsl +ADVS <- tmc_ex_advs app <- init( data = cdisc_data( - ADSL = adsl, - ADVS = advs + ADSL = ADSL, + ADVS = ADVS, + code = " + ADSL <- tmc_ex_adsl + ADVS <- tmc_ex_advs + " ), modules = modules( tm_g_pp_vitals( @@ -90,15 +94,15 @@ app <- init( patient_col = "USUBJID", plot_height = c(600L, 200L, 2000L), paramcd = choices_selected( - choices = variable_choices(advs, "PARAMCD"), + choices = variable_choices(ADVS, "PARAMCD"), selected = "PARAMCD" ), xaxis = choices_selected( - choices = variable_choices(advs, "ADY"), + choices = variable_choices(ADVS, "ADY"), selected = "ADY" ), aval = choices_selected( - choices = variable_choices(advs, "AVAL"), + choices = variable_choices(ADVS, "AVAL"), selected = "AVAL" ) ) diff --git a/man/tm_t_abnormality.Rd b/man/tm_t_abnormality.Rd index 1913ab2d96..4f69b03f8d 100644 --- a/man/tm_t_abnormality.Rd +++ b/man/tm_t_abnormality.Rd @@ -109,40 +109,43 @@ Patients with the same abnormality at baseline as on the treatment visit can be excluded in accordance with \code{GDSR} specifications by using \code{exclude_base_abn}. } \examples{ -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb \%>\% - dplyr::mutate( - ONTRTFL = dplyr::case_when( - AVISIT \%in\% c("SCREENING", "BASELINE") ~ "", - TRUE ~ "Y" - ) \%>\% formatters::with_label("On Treatment Record Flag") - ) +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb \%>\% + dplyr::mutate( + ONTRTFL = dplyr::case_when( + AVISIT \%in\% c("SCREENING", "BASELINE") ~ "", + TRUE ~ "Y" + ) \%>\% formatters::with_label("On Treatment Record Flag") + ) +}) +datanames <- c("ADSL", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADLB = adlb - ), + data = data, modules = modules( tm_t_abnormality( label = "Abnormality Table", dataname = "ADLB", arm_var = choices_selected( - choices = variable_choices(adsl, subset = c("ARM", "ARMCD")), + choices = variable_choices(data[["ADSL"]], subset = c("ARM", "ARMCD")), selected = "ARM" ), add_total = FALSE, by_vars = choices_selected( - choices = variable_choices(adlb, subset = c("LBCAT", "PARAM", "AVISIT")), + choices = variable_choices(data[["ADLB"]], subset = c("LBCAT", "PARAM", "AVISIT")), selected = c("LBCAT", "PARAM"), keep_order = TRUE ), baseline_var = teal.transform::choices_selected( - teal.transform::variable_choices(adlb, subset = "BNRIND"), + teal.transform::variable_choices(data[["ADLB"]], subset = "BNRIND"), selected = "BNRIND", fixed = TRUE ), grade = choices_selected( - choices = variable_choices(adlb, subset = "ANRIND"), + choices = variable_choices(data[["ADLB"]], subset = "ANRIND"), selected = "ANRIND", fixed = TRUE ), diff --git a/man/tm_t_abnormality_by_worst_grade.Rd b/man/tm_t_abnormality_by_worst_grade.Rd index 7336c46265..84b789bf5c 100644 --- a/man/tm_t_abnormality_by_worst_grade.Rd +++ b/man/tm_t_abnormality_by_worst_grade.Rd @@ -99,25 +99,30 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Laboratory test results with highest grade post-baseline } \examples{ -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb \%>\% +ADSL <- tmc_ex_adsl +ADLB <- tmc_ex_adlb \%>\% dplyr::filter(!AVISIT \%in\% c("SCREENING", "BASELINE")) app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb \%>\% + dplyr::filter(!AVISIT \%in\% c(\"SCREENING\", \"BASELINE\")) + " ), modules = modules( tm_t_abnormality_by_worst_grade( label = "Laboratory Test Results with Highest Grade Post-Baseline", dataname = "ADLB", arm_var = choices_selected( - choices = variable_choices(adsl, subset = c("ARM", "ARMCD")), + choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")), selected = "ARM" ), paramcd = choices_selected( - choices = value_choices(adlb, "PARAMCD", "PARAM"), + choices = value_choices(ADLB, "PARAMCD", "PARAM"), selected = c("ALT", "CRP", "IGA") ), add_total = FALSE diff --git a/man/tm_t_ancova.Rd b/man/tm_t_ancova.Rd index 0eaafd8821..7422157d9e 100644 --- a/man/tm_t_ancova.Rd +++ b/man/tm_t_ancova.Rd @@ -109,8 +109,8 @@ to be meaningful. } } \examples{ -adsl <- tmc_ex_adsl -adqs <- tmc_ex_adqs +ADSL <- tmc_ex_adsl +ADQS <- tmc_ex_adqs arm_ref_comp <- list( ARM = list( @@ -125,36 +125,40 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - ADSL = adsl, - ADQS = adqs + ADSL = ADSL, + ADQS = ADQS, + code = " + ADSL <- tmc_ex_adsl + ADQS <- tmc_ex_adqs + " ), modules = modules( tm_t_ancova( label = "ANCOVA Table", dataname = "ADQS", avisit = choices_selected( - choices = value_choices(adqs, "AVISIT"), + choices = value_choices(ADQS, "AVISIT"), selected = "WEEK 1 DAY 8" ), arm_var = choices_selected( - choices = variable_choices(adsl, c("ARM", "ACTARMCD", "ARMCD")), + choices = variable_choices(ADSL, c("ARM", "ACTARMCD", "ARMCD")), selected = "ARMCD" ), arm_ref_comp = arm_ref_comp, aval_var = choices_selected( - choices = variable_choices(adqs, c("CHG", "AVAL")), + choices = variable_choices(ADQS, c("CHG", "AVAL")), selected = "CHG" ), cov_var = choices_selected( - choices = variable_choices(adqs, c("BASE", "STRATA1", "SEX")), + choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")), selected = "STRATA1" ), paramcd = choices_selected( - choices = value_choices(adqs, "PARAMCD", "PARAM"), + choices = value_choices(ADQS, "PARAMCD", "PARAM"), selected = "FKSI-FWB" ), interact_var = choices_selected( - choices = variable_choices(adqs, c("BASE", "STRATA1", "SEX")), + choices = variable_choices(ADQS, c("BASE", "STRATA1", "SEX")), selected = "STRATA1" ) ) diff --git a/man/tm_t_binary_outcome.Rd b/man/tm_t_binary_outcome.Rd index 90c1cb6659..b2caa98c65 100644 --- a/man/tm_t_binary_outcome.Rd +++ b/man/tm_t_binary_outcome.Rd @@ -123,8 +123,8 @@ Reference arms automatically combined if multiple arms selected as reference group. } \examples{ -adsl <- tmc_ex_adsl -adrs <- tmc_ex_adrs \%>\% +ADSL <- tmc_ex_adsl +ADRS <- tmc_ex_adrs \%>\% dplyr::mutate( AVALC = tern::d_onco_rsp_label(AVALC) \%>\% formatters::with_label("Character Result/Finding") @@ -137,24 +137,33 @@ arm_ref_comp <- list( ) app <- init( data = cdisc_data( - ADSL = adsl, - ADRS = adrs + ADSL = ADSL, + ADRS = ADRS, + code = " + ADSL <- tmc_ex_adsl + ADRS <- tmc_ex_adrs \%>\% + dplyr::mutate( + AVALC = tern::d_onco_rsp_label(AVALC) \%>\% + formatters::with_label(\"Character Result/Finding\") + ) \%>\% + dplyr::filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\") + " ), modules = modules( tm_t_binary_outcome( label = "Responders", dataname = "ADRS", paramcd = choices_selected( - choices = value_choices(adrs, "PARAMCD", "PARAM"), + choices = value_choices(ADRS, "PARAMCD", "PARAM"), selected = "BESRSPI" ), arm_var = choices_selected( - choices = variable_choices(adrs, c("ARM", "ARMCD", "ACTARMCD")), + choices = variable_choices(ADRS, c("ARM", "ARMCD", "ACTARMCD")), selected = "ARM" ), arm_ref_comp = arm_ref_comp, strata_var = choices_selected( - choices = variable_choices(adrs, c("SEX", "BMRKR2", "RACE")), + choices = variable_choices(ADRS, c("SEX", "BMRKR2", "RACE")), select = "RACE" ), default_responses = list( diff --git a/man/tm_t_coxreg.Rd b/man/tm_t_coxreg.Rd index 6ffa7aa9ff..5c120d9281 100644 --- a/man/tm_t_coxreg.Rd +++ b/man/tm_t_coxreg.Rd @@ -133,8 +133,6 @@ Wald test will be substituted. ## The example below is based on the usual approach involving creation of ## a random CDISC dataset and then running the application. -adsl <- tmc_ex_adsl -adtte <- tmc_ex_adtte arm_ref_comp <- list( ACTARMCD = list( ref = "ARM B", @@ -146,11 +144,17 @@ arm_ref_comp <- list( ) ) +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + ADTTE <- tmc_ex_adtte +}) +datanames <- c("ADSL", "ADTTE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) + app <- init( - data = cdisc_data( - ADSL = adsl, - ADTTE = adtte - ), + data = data, modules = modules( tm_t_coxreg( label = "Cox Reg.", @@ -158,7 +162,7 @@ app <- init( arm_var = choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - value_choices(adtte, "PARAMCD", "PARAM"), "OS" + value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), "OS" ), strata_var = choices_selected( c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1" @@ -183,32 +187,39 @@ if (interactive()) { ## Dataset fabrication ## ------------------- -adtte <- data.frame( - STUDYID = "LUNG", - AVAL = c(4, 3, 1, 1, 2, 2, 3, 1, 2), - CNSR = c(1, 1, 1, 0, 1, 1, 0, 0, 0), - ARMCD = factor( - c(0, 1, 1, 1, 1, 0, 0, 0, 0), - labels = c("ARM A", "ARM B") - ), - SEX = factor( - c(0, 0, 0, 0, 1, 1, 1, 1, 1), - labels = c("F", "M") - ), - INST = factor(c("A", "A", "B", "B", "A", "B", "A", "B", "A")), - stringsAsFactors = FALSE -) -adtte <- base::rbind(adtte, adtte, adtte, adtte) -adtte <- dplyr::as_tibble(adtte) -set.seed(1) -adtte$INST <- sample(adtte$INST) -adtte$AGE <- sample(seq(5, 75, 5), size = nrow(adtte), replace = TRUE) -adtte$USUBJID <- paste("sub", 1:nrow(adtte), adtte$INST, sep = "-") -adtte$PARAM <- adtte$PARAMCD <- "OS" -adsl <- subset( - adtte, - select = c("USUBJID", "STUDYID", "ARMCD", "SEX", "INST", "AGE") -) +data <- teal_data() +data <- within(data, { + ADTTE <- data.frame( + STUDYID = "LUNG", + AVAL = c(4, 3, 1, 1, 2, 2, 3, 1, 2), + CNSR = c(1, 1, 1, 0, 1, 1, 0, 0, 0), + ARMCD = factor( + c(0, 1, 1, 1, 1, 0, 0, 0, 0), + labels = c("ARM A", "ARM B") + ), + SEX = factor( + c(0, 0, 0, 0, 1, 1, 1, 1, 1), + labels = c("F", "M") + ), + INST = factor(c("A", "A", "B", "B", "A", "B", "A", "B", "A")), + stringsAsFactors = FALSE + ) + ADTTE <- base::rbind(ADTTE, ADTTE, ADTTE, ADTTE) + ADTTE <- dplyr::as_tibble(ADTTE) + set.seed(1) + ADTTE$INST <- sample(ADTTE$INST) + ADTTE$AGE <- sample(seq(5, 75, 5), size = nrow(ADTTE), replace = TRUE) + ADTTE$USUBJID <- paste("sub", 1:nrow(ADTTE), ADTTE$INST, sep = "-") + ADTTE$PARAM <- ADTTE$PARAMCD <- "OS" + ADSL <- subset( + ADTTE, + select = c("USUBJID", "STUDYID", "ARMCD", "SEX", "INST", "AGE") + ) +}) + +datanames <- c("ADSL", "ADTTE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) ## Teal application ## ================ @@ -218,11 +229,7 @@ adsl <- subset( arm_ref_comp <- list(ARMCD = list(ref = "ARM A", comp = c("ARM B"))) app <- init( - data = cdisc_data( - ADSL = adsl, - ADTTE = adtte - ) - ), + data = data, modules = modules( tm_t_coxreg( label = "Cox Reg.", @@ -230,7 +237,7 @@ app <- init( arm_var = choices_selected(c("ARMCD"), "ARMCD"), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - value_choices(adtte, "PARAMCD", "PARAM"), "OS" + value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), "OS" ), strata_var = choices_selected(c("INST"), NULL), cov_var = choices_selected(c("SEX", "AGE"), "SEX"), diff --git a/man/tm_t_events.Rd b/man/tm_t_events.Rd index 889b8fb314..231f8bf68a 100644 --- a/man/tm_t_events.Rd +++ b/man/tm_t_events.Rd @@ -88,13 +88,17 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Events by Term } \examples{ -adsl <- tmc_ex_adsl -adae <- tmc_ex_adae +ADSL <- tmc_ex_adsl +ADAE <- tmc_ex_adae app <- teal::init( data = cdisc_data( - ADSL = adsl, - ADAE = adae + ADSL = ADSL, + ADAE = ADAE, + code = " + ADSL <- tmc_ex_adsl + ADAE <- tmc_ex_adae + " ), modules = modules( tm_t_events( @@ -102,11 +106,11 @@ app <- teal::init( dataname = "ADAE", arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), llt = choices_selected( - choices = variable_choices(adae, c("AETERM", "AEDECOD")), + choices = variable_choices(ADAE, c("AETERM", "AEDECOD")), selected = c("AEDECOD") ), hlt = choices_selected( - choices = variable_choices(adae, c("AEBODSYS", "AESOC")), + choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")), selected = "AEBODSYS" ), add_total = TRUE, diff --git a/man/tm_t_events_by_grade.Rd b/man/tm_t_events_by_grade.Rd index 59a835b80d..cbe361cf01 100644 --- a/man/tm_t_events_by_grade.Rd +++ b/man/tm_t_events_by_grade.Rd @@ -89,32 +89,36 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Events by Grade } \examples{ -adsl <- tmc_ex_adsl -lbls_adae <- formatters::var_labels(tmc_ex_adae) -adae <- tmc_ex_adae \%>\% - dplyr::mutate_if(is.character, as.factor) # be certain of having factors -formatters::var_labels(adae) <- lbls_adae +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + lbls_adae <- formatters::var_labels(tmc_ex_adae) + ADAE <- tmc_ex_adae \%>\% + dplyr::mutate_if(is.character, as.factor) #' be certain of having factors + formatters::var_labels(ADAE) <- lbls_adae +}) + +datanames <- c("ADSL", "ADAE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADAE = adae - ), + data = data, modules = modules( tm_t_events_by_grade( label = "Adverse Events by Grade Table", dataname = "ADAE", arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), llt = choices_selected( - choices = variable_choices(adae, c("AETERM", "AEDECOD")), + choices = variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")), selected = c("AEDECOD") ), hlt = choices_selected( - choices = variable_choices(adae, c("AEBODSYS", "AESOC")), + choices = variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")), selected = "AEBODSYS" ), grade = choices_selected( - choices = variable_choices(adae, c("AETOXGR", "AESEV")), + choices = variable_choices(data[["ADAE"]], c("AETOXGR", "AESEV")), selected = "AETOXGR" ) ) diff --git a/man/tm_t_events_patyear.Rd b/man/tm_t_events_patyear.Rd index 80ad64c0a8..12ed350550 100644 --- a/man/tm_t_events_patyear.Rd +++ b/man/tm_t_events_patyear.Rd @@ -89,33 +89,40 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal module: Event rates adjusted for patient-years } \examples{ -adsl <- tmc_ex_adsl -adaette <- tmc_ex_adaette \%>\% +ADSL <- tmc_ex_adsl +ADAETTE <- tmc_ex_adaette \%>\% dplyr::filter(PARAMCD \%in\% c("AETTE1", "AETTE2", "AETTE3")) \%>\% dplyr::mutate(is_event = CNSR == 0) \%>\% dplyr::mutate(n_events = as.integer(is_event)) app <- init( data = cdisc_data( - ADSL = adsl, - ADAETTE = adaette + ADSL = ADSL, + ADAETTE = ADAETTE, + code = " + ADSL <- tmc_ex_adsl + ADAETTE <- tmc_ex_adaette \%>\% + dplyr::filter(PARAMCD \%in\% c(\"AETTE1\", \"AETTE2\", \"AETTE3\")) \%>\% + dplyr::mutate(is_event = CNSR == 0) \%>\% + dplyr::mutate(n_events = as.integer(is_event)) + " ), modules = modules( tm_t_events_patyear( label = "AE Rate Adjusted for Patient-Years At Risk Table", dataname = "ADAETTE", arm_var = choices_selected( - choices = variable_choices(adsl, c("ARM", "ARMCD")), + choices = variable_choices(ADSL, c("ARM", "ARMCD")), selected = "ARMCD" ), add_total = TRUE, events_var = choices_selected( - choices = variable_choices(adaette, "n_events"), + choices = variable_choices(ADAETTE, "n_events"), selected = "n_events", fixed = TRUE ), paramcd = choices_selected( - choices = value_choices(adaette, "PARAMCD", "PARAM"), + choices = value_choices(ADAETTE, "PARAMCD", "PARAM"), selected = "AETTE1" ) ) diff --git a/man/tm_t_events_summary.Rd b/man/tm_t_events_summary.Rd index dd1c830f5b..abf753075e 100644 --- a/man/tm_t_events_summary.Rd +++ b/man/tm_t_events_summary.Rd @@ -110,48 +110,53 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Adverse Events Summary } \examples{ -adsl <- tmc_ex_adsl \%>\% - dplyr::mutate( - DTHFL = dplyr::case_when( # nolint - !is.na(DTHDT) ~ "Y", - TRUE ~ "" - ) \%>\% formatters::with_label("Subject Death Flag") - ) -adae <- tmc_ex_adae - -add_event_flags <- function(dat) { - dat <- dat \%>\% +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl \%>\% dplyr::mutate( - TMPFL_SER = AESER == "Y", - TMPFL_REL = AEREL == "Y", - TMPFL_GR5 = AETOXGR == "5", - TMP_SMQ01 = !is.na(SMQ01NAM), - TMP_SMQ02 = !is.na(SMQ02NAM), - TMP_CQ01 = !is.na(CQ01NAM) + DTHFL = dplyr::case_when( #' nolint + !is.na(DTHDT) ~ "Y", + TRUE ~ "" + ) \%>\% formatters::with_label("Subject Death Flag") ) - column_labels <- list( - TMPFL_SER = "Serious AE", - TMPFL_REL = "Related AE", - TMPFL_GR5 = "Grade 5 AE", - TMP_SMQ01 = aesi_label(dat[["SMQ01NAM"]], dat[["SMQ01SC"]]), - TMP_SMQ02 = aesi_label("Y.9.9.9.9/Z.9.9.9.9 AESI"), - TMP_CQ01 = aesi_label(dat[["CQ01NAM"]]) - ) - formatters::var_labels(dat)[names(column_labels)] <- as.character(column_labels) - dat -} + ADAE <- tmc_ex_adae + + add_event_flags <- function(dat) { + dat <- dat \%>\% + dplyr::mutate( + TMPFL_SER = AESER == "Y", + TMPFL_REL = AEREL == "Y", + TMPFL_GR5 = AETOXGR == "5", + TMP_SMQ01 = !is.na(SMQ01NAM), + TMP_SMQ02 = !is.na(SMQ02NAM), + TMP_CQ01 = !is.na(CQ01NAM) + ) + column_labels <- list( + TMPFL_SER = "Serious AE", + TMPFL_REL = "Related AE", + TMPFL_GR5 = "Grade 5 AE", + TMP_SMQ01 = aesi_label(dat[["SMQ01NAM"]], dat[["SMQ01SC"]]), + TMP_SMQ02 = aesi_label("Y.9.9.9.9/Z.9.9.9.9 AESI"), + TMP_CQ01 = aesi_label(dat[["CQ01NAM"]]) + ) + formatters::var_labels(dat)[names(column_labels)] <- as.character(column_labels) + dat + } + + #' Generating user-defined event flags. + ADAE <- ADAE \%>\% add_event_flags() + + ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")] + aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")] -# Generating user-defined event flags. -adae <- adae \%>\% add_event_flags() +}) -ae_anl_vars <- names(adae)[startsWith(names(adae), "TMPFL_")] -aesi_vars <- names(adae)[startsWith(names(adae), "TMP_")] +datanames <- c("ADSL", "ADAE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADAE = adae - ), + data = data, modules = modules( tm_t_events_summary( label = "Adverse Events Summary", @@ -161,14 +166,14 @@ app <- init( selected = "ARM" ), flag_var_anl = choices_selected( - choices = variable_choices("ADAE", ae_anl_vars), - selected = ae_anl_vars[1], + choices = variable_choices("ADAE", data[["ae_anl_vars"]]), + selected = data[["ae_anl_vars"]][1], keep_order = TRUE, fixed = FALSE ), flag_var_aesi = choices_selected( - choices = variable_choices("ADAE", aesi_vars), - selected = aesi_vars[1], + choices = variable_choices("ADAE", data[["aesi_vars"]]), + selected = data[["aesi_vars"]][1], keep_order = TRUE, fixed = FALSE ), diff --git a/man/tm_t_exposure.Rd b/man/tm_t_exposure.Rd index 8c6e8de616..315a26e62c 100644 --- a/man/tm_t_exposure.Rd +++ b/man/tm_t_exposure.Rd @@ -102,45 +102,49 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal module: Exposure Table for Risk management plan } \examples{ -adsl <- tmc_ex_adsl -adex <- tmc_ex_adex - -set.seed(1, kind = "Mersenne-Twister") -labels <- formatters::var_labels(adex, fill = FALSE) -adex <- adex \%>\% - dplyr::distinct(USUBJID, .keep_all = TRUE) \%>\% - dplyr::mutate( - PARAMCD = "TDURD", - PARAM = "Overall duration (days)", - AVAL = sample(x = seq(1, 200), size = dplyr::n(), replace = TRUE), - AVALU = "Days" - ) \%>\% - dplyr::bind_rows(adex) -formatters::var_labels(adex) <- labels +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + ADEX <- tmc_ex_adex + + set.seed(1, kind = "Mersenne-Twister") + labels <- formatters::var_labels(ADEX, fill = FALSE) + ADEX <- ADEX \%>\% + dplyr::distinct(USUBJID, .keep_all = TRUE) \%>\% + dplyr::mutate( + PARAMCD = "TDURD", + PARAM = "Overall duration (days)", + AVAL = sample(x = seq(1, 200), size = dplyr::n(), replace = TRUE), + AVALU = "Days" + ) \%>\% + dplyr::bind_rows(ADEX) + formatters::var_labels(ADEX) <- labels +}) + +datanames <- c("ADSL", "ADEX") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADEX = adex - ), + data = data, modules = modules( tm_t_exposure( label = "Duration of Exposure Table", dataname = "ADEX", paramcd = choices_selected( - choices = value_choices(adex, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADEX"]], "PARAMCD", "PARAM"), selected = "TDURD" ), col_by_var = choices_selected( - choices = variable_choices(adex, subset = c("SEX", "ARM")), + choices = variable_choices(data[["ADEX"]], subset = c("SEX", "ARM")), selected = "SEX" ), row_by_var = choices_selected( - choices = variable_choices(adex, subset = c("RACE", "REGION1", "STRATA1", "SEX")), + choices = variable_choices(data[["ADEX"]], subset = c("RACE", "REGION1", "STRATA1", "SEX")), selected = "RACE" ), parcat = choices_selected( - choices = value_choices(adex, "PARCAT2"), + choices = value_choices(data[["ADEX"]], "PARCAT2"), selected = "Drug A" ), add_total = FALSE diff --git a/man/tm_t_logistic.Rd b/man/tm_t_logistic.Rd index 151c3455ed..d8fd25f416 100644 --- a/man/tm_t_logistic.Rd +++ b/man/tm_t_logistic.Rd @@ -79,8 +79,8 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments This module produces a multi-variable logistic regression table that matches \code{LGRT02}. } \examples{ -adsl <- tmc_ex_adsl -adrs <- tmc_ex_adrs \%>\% +ADSL <- tmc_ex_adsl +ADRS <- tmc_ex_adrs \%>\% dplyr::filter(PARAMCD \%in\% c("BESRSPI", "INVET")) arm_ref_comp <- list( @@ -96,20 +96,25 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - ADSL = adsl, - ADRS = adrs + ADSL = ADSL, + ADRS = ADRS, + code = " + ADSL <- tmc_ex_adsl + ADRS <- tmc_ex_adrs \%>\% + dplyr::filter(PARAMCD \%in\% c("BESRSPI", "INVET")) + " ), modules = modules( tm_t_logistic( label = "Logistic Regression", dataname = "ADRS", arm_var = choices_selected( - choices = variable_choices(adrs, c("ARM", "ARMCD")), + choices = variable_choices(ADRS, c("ARM", "ARMCD")), selected = "ARM" ), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - choices = value_choices(adrs, "PARAMCD", "PARAM"), + choices = value_choices(ADRS, "PARAMCD", "PARAM"), selected = "BESRSPI" ), cov_var = choices_selected( diff --git a/man/tm_t_mult_events.Rd b/man/tm_t_mult_events.Rd index cd9e1996d1..461e44ea18 100644 --- a/man/tm_t_mult_events.Rd +++ b/man/tm_t_mult_events.Rd @@ -80,14 +80,19 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Multiple Events by Term } \examples{ -adsl <- tmc_ex_adsl -adcm <- tmc_ex_adcm +ADSL <- tmc_ex_adsl +ADCM <- tmc_ex_adcm adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") app <- teal::init( data = cdisc_data( - ADSL = adsl, - ADCM = adcm # TODO use adcm_keys + ADSL = ADSL, + ADCM = ADCM, + code = " + ADSL <- tmc_ex_adsl + ADCM <- tmc_ex_adcm + ", + join_keys = join_keys #TODO join_key ), modules = modules( tm_t_mult_events( @@ -96,11 +101,11 @@ app <- teal::init( arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), seq_var = choices_selected("CMSEQ", selected = "CMSEQ", fixed = TRUE), hlt = choices_selected( - choices = variable_choices(adcm, c("ATC1", "ATC2", "ATC3", "ATC4")), + choices = variable_choices(ADCM, c("ATC1", "ATC2", "ATC3", "ATC4")), selected = c("ATC1", "ATC2", "ATC3", "ATC4") ), llt = choices_selected( - choices = variable_choices(adcm, c("CMDECOD")), + choices = variable_choices(ADCM, c("CMDECOD")), selected = c("CMDECOD") ), add_total = TRUE, diff --git a/man/tm_t_pp_basic_info.Rd b/man/tm_t_pp_basic_info.Rd index db5e877802..951628b911 100644 --- a/man/tm_t_pp_basic_info.Rd +++ b/man/tm_t_pp_basic_info.Rd @@ -37,11 +37,12 @@ the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} This teal module produces a patient profile basic info report using \code{ADaM} datasets. } \examples{ -adsl <- tmc_ex_adsl +ADSL <- tmc_ex_adsl app <- init( data = cdisc_data( - ADSL = adsl + ADSL = ADSL, + code = "ADSL <- tmc_ex_adsl" ), modules = modules( tm_t_pp_basic_info( @@ -49,7 +50,7 @@ app <- init( dataname = "ADSL", patient_col = "USUBJID", vars = choices_selected( - choices = variable_choices(adsl), + choices = variable_choices(ADSL), selected = c("ARM", "AGE", "SEX", "COUNTRY", "RACE", "EOSSTT") ) ) diff --git a/man/tm_t_pp_laboratory.Rd b/man/tm_t_pp_laboratory.Rd index 1b7ffc2d4b..018bb94c83 100644 --- a/man/tm_t_pp_laboratory.Rd +++ b/man/tm_t_pp_laboratory.Rd @@ -61,13 +61,17 @@ the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} This teal module produces a patient profile laboratory table using \code{ADaM} datasets. } \examples{ -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb +ADSL <- tmc_ex_adsl +ADLB <- tmc_ex_adlb app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb + " ), modules = modules( tm_t_pp_laboratory( @@ -75,27 +79,27 @@ app <- init( dataname = "ADLB", patient_col = "USUBJID", paramcd = choices_selected( - choices = variable_choices(adlb, "PARAMCD"), + choices = variable_choices(ADLB, "PARAMCD"), selected = "PARAMCD" ), param = choices_selected( - choices = variable_choices(adlb, "PARAM"), + choices = variable_choices(ADLB, "PARAM"), selected = "PARAM" ), timepoints = choices_selected( - choices = variable_choices(adlb, "ADY"), + choices = variable_choices(ADLB, "ADY"), selected = "ADY" ), anrind = choices_selected( - choices = variable_choices(adlb, "ANRIND"), + choices = variable_choices(ADLB, "ANRIND"), selected = "ANRIND" ), aval = choices_selected( - choices = variable_choices(adlb, "AVAL"), + choices = variable_choices(ADLB, "AVAL"), selected = "AVAL" ), avalu = choices_selected( - choices = variable_choices(adlb, "AVALU"), + choices = variable_choices(ADLB, "AVALU"), selected = "AVALU" ) ) diff --git a/man/tm_t_pp_medical_history.Rd b/man/tm_t_pp_medical_history.Rd index 5ef48556c5..418bd879ef 100644 --- a/man/tm_t_pp_medical_history.Rd +++ b/man/tm_t_pp_medical_history.Rd @@ -49,13 +49,17 @@ the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} This teal module produces a patient medical history report using \code{ADaM} datasets. } \examples{ -adsl <- tmc_ex_adsl -admh <- tmc_ex_admh +ADSL <- tmc_ex_adsl +ADMH <- tmc_ex_admh app <- init( data = cdisc_data( - ADSL = adsl, - ADMH = admh + ADSL = ADSL, + ADMH = ADMH, + code = " + ADSL <- tmc_ex_adsl + ADMH <- tmc_ex_admh + " ), modules = modules( tm_t_pp_medical_history( @@ -64,15 +68,15 @@ app <- init( parentname = "ADSL", patient_col = "USUBJID", mhterm = choices_selected( - choices = variable_choices(admh, c("MHTERM")), + choices = variable_choices(ADMH, c("MHTERM")), selected = "MHTERM" ), mhbodsys = choices_selected( - choices = variable_choices(admh, "MHBODSYS"), + choices = variable_choices(ADMH, "MHBODSYS"), selected = "MHBODSYS" ), mhdistat = choices_selected( - choices = variable_choices(admh, "MHDISTAT"), + choices = variable_choices(ADMH, "MHDISTAT"), selected = "MHDISTAT" ) ) diff --git a/man/tm_t_pp_prior_medication.Rd b/man/tm_t_pp_prior_medication.Rd index 6ad8d78506..43c8d22205 100644 --- a/man/tm_t_pp_prior_medication.Rd +++ b/man/tm_t_pp_prior_medication.Rd @@ -53,16 +53,23 @@ the \code{\link[shiny:helpText]{shiny::helpText()}} elements are useful.} This teal module produces a patient prior medication report using \code{ADaM} datasets. } \examples{ -adcm <- tmc_ex_adcm -adsl <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% adcm$USUBJID) -adcm$CMASTDTM <- adcm$ASTDTM -adcm$CMAENDTM <- adcm$AENDTM +ADCM <- tmc_ex_adcm +ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADCM$USUBJID) +ADCM$CMASTDTM <- ADCM$ASTDTM +ADCM$CMAENDTM <- ADCM$AENDTM adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4") app <- init( data = cdisc_data( - ADSL = adsl, - ADCM = adcm + ADSL = ADSL, + ADCM = ADCM, + code = " + ADCM <- tmc_ex_adcm + ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADCM$USUBJID) + ADCM$CMASTDTM <- ADCM$ASTDTM + ADCM$CMAENDTM <- ADCM$AENDTM + ", + join_keys = join_keys #TODO Join- key ), modules = modules( tm_t_pp_prior_medication( @@ -71,19 +78,19 @@ app <- init( parentname = "ADSL", patient_col = "USUBJID", atirel = choices_selected( - choices = variable_choices(adcm, "ATIREL"), + choices = variable_choices(ADCM, "ATIREL"), selected = "ATIREL" ), cmdecod = choices_selected( - choices = variable_choices(adcm, "CMDECOD"), + choices = variable_choices(ADCM, "CMDECOD"), selected = "CMDECOD" ), cmindc = choices_selected( - choices = variable_choices(adcm, "CMINDC"), + choices = variable_choices(ADCM, "CMINDC"), selected = "CMINDC" ), cmstdy = choices_selected( - choices = variable_choices(adcm, "ASTDY"), + choices = variable_choices(ADCM, "ASTDY"), selected = "ASTDY" ) ) diff --git a/man/tm_t_shift_by_arm.Rd b/man/tm_t_shift_by_arm.Rd index 9608a67de4..67c78e4e92 100644 --- a/man/tm_t_shift_by_arm.Rd +++ b/man/tm_t_shift_by_arm.Rd @@ -96,36 +96,40 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Shift by Arm } \examples{ -adsl <- tmc_ex_adsl -adeg <- tmc_ex_adeg +ADSL <- tmc_ex_adsl +ADEG <- tmc_ex_adeg app <- init( data = cdisc_data( - ADSL = adsl, - ADEG = adeg + ADSL = ADSL, + ADEG = ADEG, + code = " + ADSL <- tmc_ex_adsl + ADEG <- tmc_ex_adeg + " ), modules = modules( tm_t_shift_by_arm( label = "Shift by Arm Table", dataname = "ADEG", arm_var = choices_selected( - variable_choices(adsl, subset = c("ARM", "ARMCD")), + variable_choices(ADSL, subset = c("ARM", "ARMCD")), selected = "ARM" ), paramcd = choices_selected( - value_choices(adeg, "PARAMCD"), + value_choices(ADEG, "PARAMCD"), selected = "HR" ), visit_var = choices_selected( - value_choices(adeg, "AVISIT"), + value_choices(ADEG, "AVISIT"), selected = "POST-BASELINE MINIMUM" ), aval_var = choices_selected( - variable_choices(adeg, subset = "ANRIND"), + variable_choices(ADEG, subset = "ANRIND"), selected = "ANRIND", fixed = TRUE ), base_var = choices_selected( - variable_choices(adeg, subset = "BNRIND"), + variable_choices(ADEG, subset = "BNRIND"), selected = "BNRIND", fixed = TRUE ), useNA = "ifany" diff --git a/man/tm_t_shift_by_arm_by_worst.Rd b/man/tm_t_shift_by_arm_by_worst.Rd index 5418951252..cba8f8ba05 100644 --- a/man/tm_t_shift_by_arm_by_worst.Rd +++ b/man/tm_t_shift_by_arm_by_worst.Rd @@ -96,40 +96,44 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Shift by Arm by Worst } \examples{ -adsl <- tmc_ex_adsl -adeg <- tmc_ex_adeg +ADSL <- tmc_ex_adsl +ADEG <- tmc_ex_adeg app <- init( data = cdisc_data( - ADSL = adsl, - ADEG = adeg + ADSL = ADSL, + ADEG = ADEG, + code = " + ADSL <- tmc_ex_adsl + ADEG <- tmc_ex_adeg + " ), modules = modules( tm_t_shift_by_arm_by_worst( label = "Shift by Arm Table", dataname = "ADEG", arm_var = choices_selected( - variable_choices(adsl, subset = c("ARM", "ARMCD")), + variable_choices(ADSL, subset = c("ARM", "ARMCD")), selected = "ARM" ), paramcd = choices_selected( - value_choices(adeg, "PARAMCD"), + value_choices(ADEG, "PARAMCD"), selected = "ECGINTP" ), worst_flag_var = choices_selected( - variable_choices(adeg, c("WORS02FL", "WORS01FL")), + variable_choices(ADEG, c("WORS02FL", "WORS01FL")), selected = "WORS02FL" ), worst_flag = choices_selected( - value_choices(adeg, "WORS02FL"), + value_choices(ADEG, "WORS02FL"), selected = "Y", fixed = TRUE ), aval_var = choices_selected( - variable_choices(adeg, c("AVALC", "ANRIND")), + variable_choices(ADEG, c("AVALC", "ANRIND")), selected = "AVALC" ), base_var = choices_selected( - variable_choices(adeg, c("BASEC", "BNRIND")), + variable_choices(ADEG, c("BASEC", "BNRIND")), selected = "BASEC" ), useNA = "ifany" diff --git a/man/tm_t_shift_by_grade.Rd b/man/tm_t_shift_by_grade.Rd index 86c557179c..93c5ad9916 100644 --- a/man/tm_t_shift_by_grade.Rd +++ b/man/tm_t_shift_by_grade.Rd @@ -110,41 +110,45 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Grade Summary Table } \examples{ -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb +ADSL <- tmc_ex_adsl +ADLB <- tmc_ex_adlb app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb + " ), modules = modules( tm_t_shift_by_grade( label = "Grade Laboratory Abnormality Table", dataname = "ADLB", arm_var = choices_selected( - choices = variable_choices(adsl, subset = c("ARM", "ARMCD")), + choices = variable_choices(ADSL, subset = c("ARM", "ARMCD")), selected = "ARM" ), paramcd = choices_selected( - choices = value_choices(adlb, "PARAMCD", "PARAM"), + choices = value_choices(ADLB, "PARAMCD", "PARAM"), selected = "ALT" ), worst_flag_var = choices_selected( - choices = variable_choices(adlb, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), + choices = variable_choices(ADLB, subset = c("WGRLOVFL", "WGRLOFL", "WGRHIVFL", "WGRHIFL")), selected = c("WGRLOVFL") ), worst_flag_indicator = choices_selected( - value_choices(adlb, "WGRLOVFL"), + value_choices(ADLB, "WGRLOVFL"), selected = "Y", fixed = TRUE ), anl_toxgrade_var = choices_selected( - choices = variable_choices(adlb, subset = c("ATOXGR")), + choices = variable_choices(ADLB, subset = c("ATOXGR")), selected = c("ATOXGR"), fixed = TRUE ), base_toxgrade_var = choices_selected( - choices = variable_choices(adlb, subset = c("BTOXGR")), + choices = variable_choices(ADLB, subset = c("BTOXGR")), selected = c("BTOXGR"), fixed = TRUE ), diff --git a/man/tm_t_smq.Rd b/man/tm_t_smq.Rd index b4577d8839..9bb06a04a8 100644 --- a/man/tm_t_smq.Rd +++ b/man/tm_t_smq.Rd @@ -94,41 +94,45 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Adverse Events Table by Standardized \code{MedDRA} Query. } \examples{ -adsl <- tmc_ex_adsl -adae <- tmc_ex_adae +data <- teal_data() +data <- within(data, { + ADSL <- tmc_ex_adsl + ADAE <- tmc_ex_adae -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 = variable_choices(adae, subset = names_baskets), - selected = names_baskets -) + cs_baskets <- choices_selected( + choices = variable_choices(ADAE, subset = names_baskets), + selected = names_baskets + ) -cs_scopes <- choices_selected( - choices = variable_choices(adae, subset = names_scopes), - selected = names_scopes, - fixed = TRUE -) + cs_scopes <- choices_selected( + choices = variable_choices(ADAE, subset = names_scopes), + selected = names_scopes, + fixed = TRUE + ) +}) + +datanames <- c("ADSL", "ADAE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- init( - data = cdisc_data( - ADSL = adsl, - ADAE = adae - ), + data = data, modules = modules( tm_t_smq( label = "Adverse Events by SMQ Table", dataname = "ADAE", arm_var = choices_selected( - choices = variable_choices(adsl, subset = c("ARM", "SEX")), + choices = variable_choices(data[["ADSL"]], subset = c("ARM", "SEX")), selected = "ARM" ), add_total = FALSE, - baskets = cs_baskets, - scopes = cs_scopes, + baskets = data[["cs_baskets"]], + scopes = data[["cs_scopes"]], llt = choices_selected( - choices = variable_choices(adae, subset = c("AEDECOD")), + choices = variable_choices(data[["ADAE"]], subset = c("AEDECOD")), selected = "AEDECOD" ) ) diff --git a/man/tm_t_summary.Rd b/man/tm_t_summary.Rd index 19fa07b333..6f99ddf8d2 100644 --- a/man/tm_t_summary.Rd +++ b/man/tm_t_summary.Rd @@ -91,18 +91,26 @@ Teal Module: Summary of Variables } \examples{ # Preparation of the test case -adsl <- tmc_ex_adsl -adsl$EOSDY[1] <- NA_integer_ +ADSL <- tmc_ex_adsl +ADSL$EOSDY[1] <- NA_integer_ # Include `EOSDY` and `DCSREAS` variables below because they contain missing data. stopifnot( - any(is.na(adsl$EOSDY)), - any(is.na(adsl$DCSREAS)) + any(is.na(ADSL$EOSDY)), + any(is.na(ADSL$DCSREAS)) ) app <- init( data = cdisc_data( - ADSL = adsl + ADSL = ADSL, + code = " + ADSL <- tmc_ex_adsl + ADSL$EOSDY[1] <- NA_integer_ + stopifnot( + any(is.na(ADSL$EOSDY)), + any(is.na(ADSL$DCSREAS)) + ) + " ), modules = modules( tm_t_summary( diff --git a/man/tm_t_summary_by.Rd b/man/tm_t_summary_by.Rd index 3d3c057ddc..2f3e63e9cc 100644 --- a/man/tm_t_summary_by.Rd +++ b/man/tm_t_summary_by.Rd @@ -116,34 +116,38 @@ For more details, see the vignette: \code{vignette("custom-basic-table-arguments Teal Module: Summarize Variables by Row Groups Module } \examples{ -adsl <- tmc_ex_adsl -adlb <- tmc_ex_adlb +ADSL <- tmc_ex_adsl +ADLB <- tmc_ex_adlb app <- init( data = cdisc_data( - ADSL = adsl, - ADLB = adlb + ADSL = ADSL, + ADLB = ADLB, + code = " + ADSL <- tmc_ex_adsl + ADLB <- tmc_ex_adlb + " ), modules = modules( tm_t_summary_by( label = "Summary by Row Groups Table", dataname = "ADLB", arm_var = choices_selected( - choices = variable_choices(adsl, c("ARM", "ARMCD")), + choices = variable_choices(ADSL, c("ARM", "ARMCD")), selected = "ARM" ), add_total = TRUE, by_vars = choices_selected( - choices = variable_choices(adlb, c("PARAM", "AVISIT")), + choices = variable_choices(ADLB, c("PARAM", "AVISIT")), selected = c("AVISIT") ), summarize_vars = choices_selected( - choices = variable_choices(adlb, c("AVAL", "CHG")), + choices = variable_choices(ADLB, c("AVAL", "CHG")), selected = c("AVAL") ), useNA = "ifany", paramcd = choices_selected( - choices = value_choices(adlb, "PARAMCD", "PARAM"), + choices = value_choices(ADLB, "PARAMCD", "PARAM"), selected = "ALT" ) ) diff --git a/man/tm_t_tte.Rd b/man/tm_t_tte.Rd index 2ebccfece7..b36ad2b89c 100644 --- a/man/tm_t_tte.Rd +++ b/man/tm_t_tte.Rd @@ -127,8 +127,8 @@ filtering for \code{paramcd} one observation per patient is expected The arm and stratification variables and taken from the \code{parentname} data. } \examples{ -adsl <- tmc_ex_adsl -adtte <- tmc_ex_adtte +ADSL <- tmc_ex_adsl +ADTTE <- tmc_ex_adtte arm_ref_comp <- list( ACTARMCD = list( @@ -143,29 +143,33 @@ arm_ref_comp <- list( app <- init( data = cdisc_data( - ADSL = adsl, - ADTTE = adtte + ADSL = ADSL, + ADTTE = ADTTE, + code = " + ADSL <- tmc_ex_adsl + ADTTE <- tmc_ex_adtte + " ), modules = modules( tm_t_tte( label = "Time To Event Table", dataname = "ADTTE", arm_var = choices_selected( - variable_choices(adsl, c("ARM", "ARMCD", "ACTARMCD")), + variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")), "ARM" ), arm_ref_comp = arm_ref_comp, paramcd = choices_selected( - value_choices(adtte, "PARAMCD", "PARAM"), + value_choices(ADTTE, "PARAMCD", "PARAM"), "OS" ), strata_var = choices_selected( - variable_choices(adsl, c("SEX", "BMRKR2")), + variable_choices(ADSL, c("SEX", "BMRKR2")), "SEX" ), time_points = choices_selected(c(182, 243), 182), event_desc_var = choices_selected( - variable_choices(adtte, "EVNTDESC"), + variable_choices(ADTTE, "EVNTDESC"), "EVNTDESC", fixed = TRUE ) From 07fd195fbf5ccf959603628a42a6a70486b6a304 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Nov 2023 16:10:59 +0530 Subject: [PATCH 04/10] fixing join_key issues. --- DESCRIPTION | 2 +- R/tm_t_mult_events.R | 6 +++++- R/tm_t_pp_prior_medication.R | 6 +++++- man/template_g_lineplot.Rd | 12 +++++------- man/tm_g_lineplot.Rd | 12 +++++------- man/tm_t_mult_events.Rd | 6 +++++- man/tm_t_pp_prior_medication.Rd | 6 +++++- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index eaee749c41..ebc2cfdd2a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -68,7 +68,7 @@ Suggests: knitr, lubridate, nestcolor (>= 0.1.0), - teal.data (>= 0.3.0), + teal.data (>= 0.3.0.9008), testthat (>= 3.0) VignetteBuilder: knitr diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index bf9eed7004..e67b6b42f1 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -292,7 +292,11 @@ template_mult_events <- function(dataname, #' ADSL <- tmc_ex_adsl #' ADCM <- tmc_ex_adcm #' ", -#' join_keys = join_keys #TODO join_key +#' join_keys = join_keys( +#' join_key("ADSL", keys = get_cdisc_keys("ADSL")), +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) +#' ) #' ), #' modules = modules( #' tm_t_mult_events( diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index 7760eb8aff..d4a023a8bd 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -88,7 +88,11 @@ template_prior_medication <- function(dataname = "ANL", #' ADCM$CMASTDTM <- ADCM$ASTDTM #' ADCM$CMAENDTM <- ADCM$AENDTM #' ", -#' join_keys = join_keys #TODO Join- key +#' join_keys = join_keys( +#' join_key("ADSL", keys = get_cdisc_keys("ADSL")), +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) +#' ) #' ), #' modules = modules( #' tm_t_pp_prior_medication( diff --git a/man/template_g_lineplot.Rd b/man/template_g_lineplot.Rd index 5c1e8881b8..149a4fc47e 100644 --- a/man/template_g_lineplot.Rd +++ b/man/template_g_lineplot.Rd @@ -30,7 +30,7 @@ template_g_lineplot( \item{dataname}{(\code{character})\cr analysis data used in teal module.} -\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} +\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -49,13 +49,11 @@ and be of a \code{double} or \code{numeric} type vector of length one.} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be -added to the plot.} +and be of a \code{double} or \code{numeric} type vector of length two.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names -of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of -\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting -\code{interval = NULL}.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} +attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, +lower or upper.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index 2cd5994f18..fc51cc68eb 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -47,7 +47,7 @@ analysis data used in teal module.} \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} -\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} +\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -65,17 +65,15 @@ value for the confidence level within the range of (0, 1).} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be -added to the plot.} +and be of a \code{double} or \code{numeric} type vector of length two.} \item{mid}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as midpoints. All the statistics indicated in \code{mid} variable must be present in the object returned by \code{sfun}, and be of a \code{double} or \code{numeric} type vector of length one.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names -of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of -\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting -\code{interval = NULL}.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} +attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, +lower or upper.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_t_mult_events.Rd b/man/tm_t_mult_events.Rd index 461e44ea18..f6a39661d9 100644 --- a/man/tm_t_mult_events.Rd +++ b/man/tm_t_mult_events.Rd @@ -92,7 +92,11 @@ app <- teal::init( ADSL <- tmc_ex_adsl ADCM <- tmc_ex_adcm ", - join_keys = join_keys #TODO join_key + join_keys = join_keys( + join_key("ADSL", keys = get_cdisc_keys("ADSL")), + join_key("ADCM", keys = adcm_keys), + join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) + ) ), modules = modules( tm_t_mult_events( diff --git a/man/tm_t_pp_prior_medication.Rd b/man/tm_t_pp_prior_medication.Rd index 43c8d22205..d94dc8d1f3 100644 --- a/man/tm_t_pp_prior_medication.Rd +++ b/man/tm_t_pp_prior_medication.Rd @@ -69,7 +69,11 @@ app <- init( ADCM$CMASTDTM <- ADCM$ASTDTM ADCM$CMAENDTM <- ADCM$AENDTM ", - join_keys = join_keys #TODO Join- key + join_keys = join_keys( + join_key("ADSL", keys = get_cdisc_keys("ADSL")), + join_key("ADCM", keys = adcm_keys), + join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) + ) ), modules = modules( tm_t_pp_prior_medication( From f3d62963dfc2ef30069995b710ad3b00512a32cb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Nov 2023 16:53:16 +0530 Subject: [PATCH 05/10] included code vignettes and fixing notes --- R/tm_g_barchart_simple.R | 12 +++++++---- R/tm_g_pp_therapy.R | 2 +- R/tm_t_logistic.R | 2 +- man/tm_g_barchart_simple.Rd | 12 +++++++---- man/tm_g_pp_therapy.Rd | 2 +- man/tm_t_logistic.Rd | 2 +- vignettes/teal-modules-clinical.Rmd | 32 ++++++++++++++++++----------- 7 files changed, 40 insertions(+), 24 deletions(-) diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index 2c6e08ca63..6cd0c80f77 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -16,17 +16,21 @@ #' @examples #' library(nestcolor) #' -#' ADSL <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor("Y") %>% +#' ADSL <- tmc_ex_adsl %>% +#' dplyr::mutate(ITTFL = factor("Y") %>% #' formatters::with_label("Intent-To-Treat Population Flag")) -#' ADAE <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) +#' ADAE <- tmc_ex_adae %>% +#' dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) #' #' app <- init( #' data = cdisc_data( #' ADSL = ADSL, #' ADAE = ADAE, -#' code = "ADSL <- tmc_ex_adsl %>% dplyr::mutate(ITTFL = factor(\"Y\") %>% +#' code = "ADSL <- tmc_ex_adsl %>% +#' dplyr::mutate(ITTFL = factor(\"Y\") %>% #' formatters::with_label(\"Intent-To-Treat Population Flag\")) -#' ADAE <- tmc_ex_adae %>% dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))" +#' ADAE <- tmc_ex_adae %>% +#' dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))" #' ), #' modules = modules( #' tm_g_barchart_simple( diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index 36e651ebe0..4c45587fb5 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -272,7 +272,7 @@ template_therapy <- function(dataname = "ANL", #' app <- init( #' data = cdisc_data( #' ADSL = ADSL, -#' ADCM = adcm, +#' ADCM = ADCM, #' code = " #' ADCM <- tmc_ex_adcm #' ADSL <- tmc_ex_adsl %>% dplyr::filter(USUBJID %in% ADCM$USUBJID) diff --git a/R/tm_t_logistic.R b/R/tm_t_logistic.R index 36bc96b4c0..ea3250f093 100644 --- a/R/tm_t_logistic.R +++ b/R/tm_t_logistic.R @@ -250,7 +250,7 @@ template_logistic <- function(dataname, #' code = " #' ADSL <- tmc_ex_adsl #' ADRS <- tmc_ex_adrs %>% -#' dplyr::filter(PARAMCD %in% c("BESRSPI", "INVET")) +#' dplyr::filter(PARAMCD %in% c(\"BESRSPI\", \"INVET\")) #' " #' ), #' modules = modules( diff --git a/man/tm_g_barchart_simple.Rd b/man/tm_g_barchart_simple.Rd index 1762723b01..2415eab6c9 100644 --- a/man/tm_g_barchart_simple.Rd +++ b/man/tm_g_barchart_simple.Rd @@ -65,17 +65,21 @@ it is ignored. \examples{ library(nestcolor) -ADSL <- tmc_ex_adsl \%>\% dplyr::mutate(ITTFL = factor("Y") \%>\% +ADSL <- tmc_ex_adsl \%>\% + dplyr::mutate(ITTFL = factor("Y") \%>\% formatters::with_label("Intent-To-Treat Population Flag")) -ADAE <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) +ADAE <- tmc_ex_adae \%>\% + dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) app <- init( data = cdisc_data( ADSL = ADSL, ADAE = ADAE, - code = "ADSL <- tmc_ex_adsl \%>\% dplyr::mutate(ITTFL = factor(\"Y\") \%>\% + code = "ADSL <- tmc_ex_adsl \%>\% + dplyr::mutate(ITTFL = factor(\"Y\") \%>\% formatters::with_label(\"Intent-To-Treat Population Flag\")) - ADAE <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))" + ADAE <- tmc_ex_adae \%>\% + dplyr::filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))" ), modules = modules( tm_g_barchart_simple( diff --git a/man/tm_g_pp_therapy.Rd b/man/tm_g_pp_therapy.Rd index 7fe375ae5a..fc5d7dcbf3 100644 --- a/man/tm_g_pp_therapy.Rd +++ b/man/tm_g_pp_therapy.Rd @@ -111,7 +111,7 @@ adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", app <- init( data = cdisc_data( ADSL = ADSL, - ADCM = adcm, + ADCM = ADCM, code = " ADCM <- tmc_ex_adcm ADSL <- tmc_ex_adsl \%>\% dplyr::filter(USUBJID \%in\% ADCM$USUBJID) diff --git a/man/tm_t_logistic.Rd b/man/tm_t_logistic.Rd index d8fd25f416..d652cba42c 100644 --- a/man/tm_t_logistic.Rd +++ b/man/tm_t_logistic.Rd @@ -101,7 +101,7 @@ app <- init( code = " ADSL <- tmc_ex_adsl ADRS <- tmc_ex_adrs \%>\% - dplyr::filter(PARAMCD \%in\% c("BESRSPI", "INVET")) + dplyr::filter(PARAMCD \%in\% c(\"BESRSPI\", \"INVET\")) " ), modules = modules( diff --git a/vignettes/teal-modules-clinical.Rmd b/vignettes/teal-modules-clinical.Rmd index 3358c622a3..03d66eba1e 100644 --- a/vignettes/teal-modules-clinical.Rmd +++ b/vignettes/teal-modules-clinical.Rmd @@ -52,13 +52,17 @@ A simple application including a bar chart module could look like this: library(teal.modules.clinical) library(nestcolor) -adsl <- tmc_ex_adsl -adae <- tmc_ex_adae +ADSL <- tmc_ex_adsl +ADAE <- tmc_ex_adae app <- teal::init( data = teal.data::cdisc_data( - ADSL = adsl, - ADAE = adae + ADSL = ADSL, + ADAE = ADAE, + code = " + ADSL <- tmc_ex_adsl + ADAE <- tmc_ex_adae + " ), modules = list( tm_g_barchart_simple( @@ -66,7 +70,7 @@ app <- teal::init( x = teal.transform::data_extract_spec( dataname = "ADAE", select = teal.transform::select_spec( - choices = teal.transform::variable_choices(adae), + choices = teal.transform::variable_choices(ADAE), multiple = FALSE ) ) @@ -90,8 +94,8 @@ library(nestcolor) ``` The above lines load the libraries used in this example. We will use the example data provided in the `teal.modules.clinical` package: ```r -adsl <- tmc_ex_adsl -adae <- tmc_ex_adae +ADSL <- tmc_ex_adsl +ADAE <- tmc_ex_adae ``` `nestcolor` is an optional package that can be loaded in to apply the standardized NEST color palette to all module plots. @@ -103,15 +107,19 @@ argument indicates the modules included in the application. Here, we include onl ```r app <- teal::init( data = teal.data::cdisc_data( - ADSL = adsl, - ADAE = adae + ADSL = ADSL, + ADAE = ADAE, + code = " + ADSL <- tmc_ex_adsl + ADAE <- tmc_ex_adae + " ), modules = list( tm_g_barchart_simple( label = "ADAE Analysis", x = teal.transform::data_extract_spec( dataname = "ADAE", - select = teal.transform::select_spec(choices = teal.transform::variable_choices(adae), multiple = FALSE) + select = teal.transform::select_spec(choices = teal.transform::variable_choices(ADAE), multiple = FALSE) ) ) ) @@ -126,9 +134,9 @@ if (interactive()) shiny::shinyApp(app$ui, app$server) Some of `teal.modules.clinical` modules allow specifying arguments using `teal.transform::choices_selected` such as `tm_t_summary` module in this example: ```r -adsl <- tmc_ex_adsl +ADSL <- tmc_ex_adsl app <- teal::init( - data = teal.data::cdisc_data(ADSL = adsl), + data = teal.data::cdisc_data(ADSL = ADSL, code = "ADSL <- tmc_ex_adsl"), modules = list( tm_t_summary( label = "Demographic Table", From a5643f4c279d8263193c652665f39bfab69790cd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Nov 2023 19:46:04 +0530 Subject: [PATCH 06/10] addressing comment. --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 0977b53a1b..d5858f3da2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,7 +13,7 @@ * Updated `tm_t_pp_basic_info`, `tm_t_pp_medical_history`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to print patient ID above table. * Updated `tm_t_pp_basic_info`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to use `rlistings` to print data neatly in reports. * Updated `tm_g_lineplot` to allow user to remove interval from plot. -* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to teal::init(). +* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`. ### Bug fixes * Fixed bug in `tm_t_coxreg` preventing table from being displayed when no covariates are selected. From bbbee7169088dade5c0d66bc8329897694eea31b 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: Wed, 8 Nov 2023 14:27:56 +0000 Subject: [PATCH 07/10] [skip actions] Roxygen Man Pages Auto Update --- man/template_g_lineplot.Rd | 12 +++++++----- man/tm_g_lineplot.Rd | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/man/template_g_lineplot.Rd b/man/template_g_lineplot.Rd index 149a4fc47e..5c1e8881b8 100644 --- a/man/template_g_lineplot.Rd +++ b/man/template_g_lineplot.Rd @@ -30,7 +30,7 @@ template_g_lineplot( \item{dataname}{(\code{character})\cr analysis data used in teal module.} -\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} +\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -49,11 +49,13 @@ and be of a \code{double} or \code{numeric} type vector of length one.} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two.} +and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be +added to the plot.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} -attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, -lower or upper.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names +of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of +\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting +\code{interval = NULL}.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index fc51cc68eb..2cd5994f18 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -47,7 +47,7 @@ analysis data used in teal module.} \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} -\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} +\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -65,15 +65,17 @@ value for the confidence level within the range of (0, 1).} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two.} +and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be +added to the plot.} \item{mid}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as midpoints. All the statistics indicated in \code{mid} variable must be present in the object returned by \code{sfun}, and be of a \code{double} or \code{numeric} type vector of length one.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} -attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, -lower or upper.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names +of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of +\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting +\code{interval = NULL}.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} From cb4bccc4c9b66c707529605efb59353fc610ca4c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Nov 2023 20:24:53 +0530 Subject: [PATCH 08/10] fixing styling and rd files --- R/tm_g_barchart_simple.R | 2 +- R/tm_g_ipp.R | 10 +++++++--- R/tm_g_pp_patient_timeline.R | 2 +- R/tm_g_pp_therapy.R | 4 ++-- R/tm_t_events_summary.R | 1 - R/tm_t_mult_events.R | 4 ++-- R/tm_t_pp_prior_medication.R | 4 ++-- man/template_g_lineplot.Rd | 12 +++++------- man/tm_g_barchart_simple.Rd | 2 +- man/tm_g_ipp.Rd | 10 +++++++--- man/tm_g_lineplot.Rd | 12 +++++------- man/tm_g_pp_patient_timeline.Rd | 2 +- man/tm_g_pp_therapy.Rd | 4 ++-- man/tm_t_events_summary.Rd | 1 - man/tm_t_mult_events.Rd | 4 ++-- man/tm_t_pp_prior_medication.Rd | 4 ++-- 16 files changed, 40 insertions(+), 38 deletions(-) diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index 6cd0c80f77..0d8ca890ca 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -18,7 +18,7 @@ #' #' ADSL <- tmc_ex_adsl %>% #' dplyr::mutate(ITTFL = factor("Y") %>% -#' formatters::with_label("Intent-To-Treat Population Flag")) +#' formatters::with_label("Intent-To-Treat Population Flag")) #' ADAE <- tmc_ex_adae %>% #' dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) #' diff --git a/R/tm_g_ipp.R b/R/tm_g_ipp.R index fa88483485..580b12a1a5 100644 --- a/R/tm_g_ipp.R +++ b/R/tm_g_ipp.R @@ -188,9 +188,13 @@ template_g_ipp <- function(dataname = "ANL", #' @examples #' library(nestcolor) #' -#' ADSL <- tmc_ex_adsl %>% dplyr::slice(1:20) %>% df_explicit_na() -#' ADLB <- tmc_ex_adlb %>% dplyr::filter(USUBJID %in% ADSL$USUBJID) %>% -#' df_explicit_na() %>% dplyr::filter(AVISIT != "SCREENING") +#' ADSL <- tmc_ex_adsl %>% +#' dplyr::slice(1:20) %>% +#' df_explicit_na() +#' ADLB <- tmc_ex_adlb %>% +#' dplyr::filter(USUBJID %in% ADSL$USUBJID) %>% +#' df_explicit_na() %>% +#' dplyr::filter(AVISIT != "SCREENING") #' #' app <- init( #' data = cdisc_data( diff --git a/R/tm_g_pp_patient_timeline.R b/R/tm_g_pp_patient_timeline.R index 8b40e6fc79..25b23f9135 100644 --- a/R/tm_g_pp_patient_timeline.R +++ b/R/tm_g_pp_patient_timeline.R @@ -376,7 +376,7 @@ template_patient_timeline <- function(dataname = "ANL", #' #' datanames(data) <- c("ADSL", "ADAE", "ADCM") #' data@join_keys <- join_keys( -#' join_key("ADSL",keys = get_cdisc_keys("ADSL")), +#' join_key("ADSL", keys = get_cdisc_keys("ADSL")), #' join_key("ADAE", keys = get_cdisc_keys("ADAE")), #' join_key("ADCM", keys = adcm_keys), #' join_key("ADAE", "ADSL", c("USUBJID", "STUDYID")), diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index 4c45587fb5..9ecf0071f6 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -281,8 +281,8 @@ template_therapy <- function(dataname = "ANL", #' ", #' join_keys = join_keys( #' join_key("ADSL", keys = get_cdisc_keys("ADSL")), -#' join_key("ADCM", keys = adcm_keys), -#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) #' ) #' ), #' modules = modules( diff --git a/R/tm_t_events_summary.R b/R/tm_t_events_summary.R index 600a552d40..9c432a4dab 100644 --- a/R/tm_t_events_summary.R +++ b/R/tm_t_events_summary.R @@ -534,7 +534,6 @@ template_events_summary <- function(anl_name, #' #' ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")] #' aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")] -#' #' }) #' #' datanames <- c("ADSL", "ADAE") diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index e67b6b42f1..9d433c9263 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -294,8 +294,8 @@ template_mult_events <- function(dataname, #' ", #' join_keys = join_keys( #' join_key("ADSL", keys = get_cdisc_keys("ADSL")), -#' join_key("ADCM", keys = adcm_keys), -#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) #' ) #' ), #' modules = modules( diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index d4a023a8bd..57c7a192f8 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -90,8 +90,8 @@ template_prior_medication <- function(dataname = "ANL", #' ", #' join_keys = join_keys( #' join_key("ADSL", keys = get_cdisc_keys("ADSL")), -#' join_key("ADCM", keys = adcm_keys), -#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) +#' join_key("ADCM", keys = adcm_keys), +#' join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) #' ) #' ), #' modules = modules( diff --git a/man/template_g_lineplot.Rd b/man/template_g_lineplot.Rd index 5c1e8881b8..149a4fc47e 100644 --- a/man/template_g_lineplot.Rd +++ b/man/template_g_lineplot.Rd @@ -30,7 +30,7 @@ template_g_lineplot( \item{dataname}{(\code{character})\cr analysis data used in teal module.} -\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} +\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -49,13 +49,11 @@ and be of a \code{double} or \code{numeric} type vector of length one.} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be -added to the plot.} +and be of a \code{double} or \code{numeric} type vector of length two.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names -of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of -\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting -\code{interval = NULL}.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} +attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, +lower or upper.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_g_barchart_simple.Rd b/man/tm_g_barchart_simple.Rd index 2415eab6c9..cdbea3348d 100644 --- a/man/tm_g_barchart_simple.Rd +++ b/man/tm_g_barchart_simple.Rd @@ -67,7 +67,7 @@ library(nestcolor) ADSL <- tmc_ex_adsl \%>\% dplyr::mutate(ITTFL = factor("Y") \%>\% - formatters::with_label("Intent-To-Treat Population Flag")) + formatters::with_label("Intent-To-Treat Population Flag")) ADAE <- tmc_ex_adae \%>\% dplyr::filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))) diff --git a/man/tm_g_ipp.Rd b/man/tm_g_ipp.Rd index 4ab0792cfe..fe57c34f73 100644 --- a/man/tm_g_ipp.Rd +++ b/man/tm_g_ipp.Rd @@ -108,9 +108,13 @@ trends in parameter values over time for each patient using data with \examples{ library(nestcolor) -ADSL <- tmc_ex_adsl \%>\% dplyr::slice(1:20) \%>\% df_explicit_na() -ADLB <- tmc_ex_adlb \%>\% dplyr::filter(USUBJID \%in\% ADSL$USUBJID) \%>\% - df_explicit_na() \%>\% dplyr::filter(AVISIT != "SCREENING") +ADSL <- tmc_ex_adsl \%>\% + dplyr::slice(1:20) \%>\% + df_explicit_na() +ADLB <- tmc_ex_adlb \%>\% + dplyr::filter(USUBJID \%in\% ADSL$USUBJID) \%>\% + df_explicit_na() \%>\% + dplyr::filter(AVISIT != "SCREENING") app <- init( data = cdisc_data( diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index 2cd5994f18..fc51cc68eb 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -47,7 +47,7 @@ analysis data used in teal module.} \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} -\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} +\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -65,17 +65,15 @@ value for the confidence level within the range of (0, 1).} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be -added to the plot.} +and be of a \code{double} or \code{numeric} type vector of length two.} \item{mid}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as midpoints. All the statistics indicated in \code{mid} variable must be present in the object returned by \code{sfun}, and be of a \code{double} or \code{numeric} type vector of length one.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names -of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of -\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting -\code{interval = NULL}.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} +attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, +lower or upper.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_g_pp_patient_timeline.Rd b/man/tm_g_pp_patient_timeline.Rd index 5748a193bb..fdbeb5c27e 100644 --- a/man/tm_g_pp_patient_timeline.Rd +++ b/man/tm_g_pp_patient_timeline.Rd @@ -128,7 +128,7 @@ data <- within(data, { datanames(data) <- c("ADSL", "ADAE", "ADCM") data@join_keys <- join_keys( - join_key("ADSL",keys = get_cdisc_keys("ADSL")), + join_key("ADSL", keys = get_cdisc_keys("ADSL")), join_key("ADAE", keys = get_cdisc_keys("ADAE")), join_key("ADCM", keys = adcm_keys), join_key("ADAE", "ADSL", c("USUBJID", "STUDYID")), diff --git a/man/tm_g_pp_therapy.Rd b/man/tm_g_pp_therapy.Rd index fc5d7dcbf3..086766c094 100644 --- a/man/tm_g_pp_therapy.Rd +++ b/man/tm_g_pp_therapy.Rd @@ -120,8 +120,8 @@ app <- init( ", join_keys = join_keys( join_key("ADSL", keys = get_cdisc_keys("ADSL")), - join_key("ADCM", keys = adcm_keys), - join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) + join_key("ADCM", keys = adcm_keys), + join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) ) ), modules = modules( diff --git a/man/tm_t_events_summary.Rd b/man/tm_t_events_summary.Rd index abf753075e..a42c143362 100644 --- a/man/tm_t_events_summary.Rd +++ b/man/tm_t_events_summary.Rd @@ -148,7 +148,6 @@ data <- within(data, { ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")] aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")] - }) datanames <- c("ADSL", "ADAE") diff --git a/man/tm_t_mult_events.Rd b/man/tm_t_mult_events.Rd index f6a39661d9..ca6662fb64 100644 --- a/man/tm_t_mult_events.Rd +++ b/man/tm_t_mult_events.Rd @@ -94,8 +94,8 @@ app <- teal::init( ", join_keys = join_keys( join_key("ADSL", keys = get_cdisc_keys("ADSL")), - join_key("ADCM", keys = adcm_keys), - join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) + join_key("ADCM", keys = adcm_keys), + join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) ) ), modules = modules( diff --git a/man/tm_t_pp_prior_medication.Rd b/man/tm_t_pp_prior_medication.Rd index d94dc8d1f3..56863d1def 100644 --- a/man/tm_t_pp_prior_medication.Rd +++ b/man/tm_t_pp_prior_medication.Rd @@ -71,8 +71,8 @@ app <- init( ", join_keys = join_keys( join_key("ADSL", keys = get_cdisc_keys("ADSL")), - join_key("ADCM", keys = adcm_keys), - join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) + join_key("ADCM", keys = adcm_keys), + join_key("ADCM", "ADSL", keys = c("USUBJID", "STUDYID")) ) ), modules = modules( From 00ecbf56386eab4daa413590b10b4403c4d7974c 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: Wed, 8 Nov 2023 15:11:35 +0000 Subject: [PATCH 09/10] [skip actions] Roxygen Man Pages Auto Update --- man/template_g_lineplot.Rd | 12 +++++++----- man/tm_g_lineplot.Rd | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/man/template_g_lineplot.Rd b/man/template_g_lineplot.Rd index 149a4fc47e..5c1e8881b8 100644 --- a/man/template_g_lineplot.Rd +++ b/man/template_g_lineplot.Rd @@ -30,7 +30,7 @@ template_g_lineplot( \item{dataname}{(\code{character})\cr analysis data used in teal module.} -\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} +\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -49,11 +49,13 @@ and be of a \code{double} or \code{numeric} type vector of length one.} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two.} +and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be +added to the plot.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} -attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, -lower or upper.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names +of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of +\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting +\code{interval = NULL}.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} diff --git a/man/tm_g_lineplot.Rd b/man/tm_g_lineplot.Rd index fc51cc68eb..2cd5994f18 100644 --- a/man/tm_g_lineplot.Rd +++ b/man/tm_g_lineplot.Rd @@ -47,7 +47,7 @@ analysis data used in teal module.} \item{parentname}{(\code{character})\cr parent analysis data used in teal module, usually this refers to \code{ADSL}.} -\item{strata}{(\code{character} or \code{NA})\cr strata variable name.} +\item{strata}{(\code{character} or \code{NA})\cr deprecated - group variable name.} \item{x}{(\code{character})\cr x variable name.} @@ -65,15 +65,17 @@ value for the confidence level within the range of (0, 1).} \item{interval}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as intervals. All the statistics indicated in \code{interval} variable must be present in the object returned by \code{sfun}, -and be of a \code{double} or \code{numeric} type vector of length two.} +and be of a \code{double} or \code{numeric} type vector of length two. Set \code{interval = NULL} if intervals should not be +added to the plot.} \item{mid}{(\code{character} or \code{NULL})\cr names of the statistics that will be plotted as midpoints. All the statistics indicated in \code{mid} variable must be present in the object returned by \code{sfun}, and be of a \code{double} or \code{numeric} type vector of length one.} -\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Must match the \code{names} -attribute of the \code{interval} element in the list returned by \code{sfun}. It is possible to specify one whisker only, -lower or upper.} +\item{whiskers}{(\code{character})\cr names of the interval whiskers that will be plotted. Names must match names +of the list element \code{interval} that will be returned by \code{sfun} (e.g. \code{mean_ci_lwr} element of +\code{sfun(x)[["mean_ci"]]}). It is possible to specify one whisker only, or to suppress all whiskers by setting +\code{interval = NULL}.} \item{table}{(\code{character} or \code{NULL})\cr names of the statistics that will be displayed in the table below the plot. All the statistics indicated in \code{table} variable must be present in the object returned by \code{sfun}.} From b56085097280d7be343950f166744e609fe1681b Mon Sep 17 00:00:00 2001 From: kartikeyakirar Date: Thu, 9 Nov 2023 11:59:44 +0530 Subject: [PATCH 10/10] 'Empty-Commit'