From d09651fa085603aab678dbb425b9a083bf3982eb Mon Sep 17 00:00:00 2001 From: vedhav Date: Tue, 7 Nov 2023 18:30:47 +0530 Subject: [PATCH] docs: update the vignettes to use the new teal_data object --- vignettes/teal-modules-general.Rmd | 41 ++++-- vignettes/using-association-plot.Rmd | 98 +++++++------ vignettes/using-bivariate-plot.Rmd | 187 ++++++++++++------------- vignettes/using-cross-table.Rmd | 75 ++++------ vignettes/using-data-table.Rmd | 21 ++- vignettes/using-outliers-module.Rmd | 48 ++++--- vignettes/using-regression-plots.Rmd | 99 ++++++------- vignettes/using-response-plot.Rmd | 129 ++++++++--------- vignettes/using-scatterplot-matrix.Rmd | 71 ++++------ vignettes/using-scatterplot.Rmd | 121 +++++++--------- 10 files changed, 408 insertions(+), 482 deletions(-) diff --git a/vignettes/teal-modules-general.Rmd b/vignettes/teal-modules-general.Rmd index 63ba8ce21..8292e1aeb 100644 --- a/vignettes/teal-modules-general.Rmd +++ b/vignettes/teal-modules-general.Rmd @@ -43,15 +43,17 @@ A simple application including a `tm_variable_browser` module could look like th ```{r, message = FALSE, results = "hide"} library(teal.modules.general) -ADSL <- teal.modules.general::rADSL # nolint -ADTTE <- teal.modules.general::rADTTE # nolint +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADTTE <- teal.modules.general::rADTTE +}) +datanames <- c("ADSL", "ADTTE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", x = ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset("ADTTE", x = ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - check = TRUE - ), + data = data, modules = teal::modules( tm_variable_browser( label = "Variable browser", @@ -72,10 +74,25 @@ Let's break the above app into pieces: library(teal.modules.general) ``` The line mentioned above imports the library required for this example and loads data from within that library. + +Now, we are building a `teal_data` object that will serve as the source of data for the teal app. +`teal_data` not only encapsulates the data for the app, but it also houses the code required to create the data to maintain reproducibility. +To do this, we create an empty `teal_data` object and evaluate code to produce the data within the `teal_data` object, +so both the code and data are stored together. + +Following this, we set the `datanames` and `join_keys`. + ```r -ADSL <- teal.modules.general::rADSL -ADAE <- teal.modules.general::rADAE +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADTTE <- teal.modules.general::rADTTE +}) +datanames <- c("ADSL", "ADTTE") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) ``` + There is no need to load `teal` as `teal.modules.general` already depends on it. In the next step, we use `teal` to create `shiny` `ui` and `server` functions so we can launch using `shiny`. The `data` @@ -84,11 +101,7 @@ argument indicates the modules included in the application. Here, we include onl ```{r, results = "hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", x = ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset("ADTTE", x = ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - check = TRUE # to check if the code executes to the data provided, x, i.e. ADSL and ADTTE - ), + data = data, modules = teal::modules( tm_variable_browser( # module name to display in the GUI diff --git a/vignettes/using-association-plot.Rmd b/vignettes/using-association-plot.Rmd index fd2b25e16..ce5e32321 100644 --- a/vignettes/using-association-plot.Rmd +++ b/vignettes/using-association-plot.Rmd @@ -61,30 +61,28 @@ itself will be constructed by multiple calls of `tm_g_association` using differe combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADSL2 <- ADSL %>% + mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) + ADRS <- teal.modules.general::rADRS + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADSL2", "ADRS", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) +data@join_keys$mutate( + "ADSL2", "ADSL", get_cdisc_keys("ADSL") +) app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset( - "ADSL2", - ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset( - "ADLB", - ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( # tm_g_association ---- modules( @@ -95,7 +93,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = "AGE", fixed = FALSE ) @@ -104,7 +102,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = "BMRKR1", multiple = TRUE, fixed = FALSE @@ -117,7 +115,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data@env$ADSL, c("AGE", "SEX", "STRATA1", "RACE")), selected = "STRATA1", multiple = FALSE, fixed = FALSE @@ -127,7 +125,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL2, c("AGE", "SEX", "RACE", "COUNTRY")), selected = c("AGE", "COUNTRY", "RACE"), multiple = TRUE, fixed = FALSE @@ -140,7 +138,7 @@ app <- teal::init( dataname = "ADTTE", select = select_spec( label = "Select variables:", - choices = variable_choices(ADTTE), + choices = variable_choices(data@env$ADTTE), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -148,7 +146,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select endpoint:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADTTE, "PARAMCD", "PARAM"), selected = c("PFS", "EFS"), multiple = TRUE ) @@ -158,7 +156,7 @@ app <- teal::init( reshape = TRUE, select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("AVALC", "BMRKR1", "BMRKR2", "ARM")), + choices = variable_choices(data@env$ADRS, c("AVALC", "BMRKR1", "BMRKR2", "ARM")), selected = "AVALC", multiple = TRUE, fixed = FALSE @@ -167,14 +165,14 @@ app <- teal::init( filter_spec( label = "Select endpoints:", vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADRS, "PARAMCD", "PARAM"), selected = "BESRSPI", multiple = TRUE ), filter_spec( label = "Select endpoints:", vars = "AVISIT", - choices = levels(ADRS$AVISIT), + choices = levels(data@env$ADRS$AVISIT), selected = "SCREENING", multiple = TRUE ) @@ -186,7 +184,7 @@ app <- teal::init( ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "AVALC")), + choices = variable_choices(data@env$ADRS, c("AVAL", "AVALC")), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -195,15 +193,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD), + choices = value_choices(data@env$ADRS, "PARAMCD", "PARAM"), + selected = levels(data@env$ADRS$PARAMCD), multiple = TRUE, label = "Select response" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT), + choices = levels(data@env$ADRS$AVISIT), + selected = levels(data@env$ADRS$AVISIT), multiple = TRUE, label = "Select visit:" ) @@ -212,7 +210,7 @@ app <- teal::init( vars = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "AGE", "RACE", "COUNTRY", "BMRKR1", "STRATA1", "ARM")), + choices = variable_choices(data@env$ADSL, c("SEX", "AGE", "RACE", "COUNTRY", "BMRKR1", "STRATA1", "ARM")), selected = "AGE", multiple = TRUE, fixed = FALSE, @@ -225,7 +223,7 @@ app <- teal::init( ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data@env$ADRS), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -235,7 +233,7 @@ app <- teal::init( vars = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data@env$ADRS), selected = "PARAMCD", multiple = TRUE, fixed = FALSE, @@ -250,21 +248,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("AVAL", "CHG2", "PCHG2")), + choices = variable_choices(data@env$ADLB, c("AVAL", "CHG2", "PCHG2")), selected = "AVAL", multiple = FALSE ) @@ -274,21 +272,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data@env$ADLB), selected = "STRATA1", multiple = TRUE ) diff --git a/vignettes/using-bivariate-plot.Rmd b/vignettes/using-bivariate-plot.Rmd index 0be71d829..adbeed28d 100644 --- a/vignettes/using-bivariate-plot.Rmd +++ b/vignettes/using-bivariate-plot.Rmd @@ -41,19 +41,26 @@ Inside this app 5 datasets will be used 5. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) -ADRS <- teal.modules.general::rADRS -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ "N", - CHG > 1 ~ "P", - TRUE ~ "-" - ))) -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADSL2 <- teal.modules.general::rADSL %>% + mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) + ADRS <- teal.modules.general::rADRS + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADSL2", "ADRS", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) +data@join_keys$mutate( + "ADSL2", "ADSL", get_cdisc_keys("ADSL") +) ``` ## Create an `app` variable @@ -65,29 +72,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset( - "ADSL2", - ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset( - "ADLB", - ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( # tm_g_bivariate ------ modules( @@ -98,7 +83,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = "BMRKR1", fixed = FALSE ) @@ -107,7 +92,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = "SEX", multiple = FALSE, fixed = FALSE @@ -117,7 +102,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = NULL, multiple = FALSE, fixed = FALSE @@ -127,7 +112,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = NULL, multiple = FALSE, fixed = FALSE @@ -140,7 +125,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "AGE", "SEX", "STRATA1", "RACE")), selected = c("BMRKR1"), multiple = FALSE ) @@ -149,7 +134,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("COUNTRY", "AGE", "RACE")), + choices = variable_choices(data@env$ADSL2, c("COUNTRY", "AGE", "RACE")), selected = "RACE", multiple = FALSE ) @@ -158,7 +143,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = NULL, multiple = FALSE, fixed = FALSE @@ -168,7 +153,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2), + choices = variable_choices(data@env$ADSL2), selected = NULL, multiple = FALSE, fixed = FALSE @@ -182,12 +167,12 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select endpoints:", vars = c("PARAMCD", "AVISIT"), - choices = value_choices(ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), + choices = value_choices(data@env$ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), selected = "OVRINV - END OF INDUCTION", multiple = TRUE ), select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data@env$ADRS, c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE ) @@ -196,7 +181,7 @@ app <- teal::init( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE, c("AVAL", "CNSR")), + choices = variable_choices(data@env$ADTTE, c("AVAL", "CNSR")), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -204,7 +189,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select endpoint:", vars = c("PARAMCD"), - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADTTE, "PARAMCD", "PARAM"), selected = "OS", multiple = FALSE ) @@ -214,13 +199,13 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select endpoints:", vars = c("PARAMCD", "AVISIT"), - choices = value_choices(ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), + choices = value_choices(data@env$ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), selected = "OVRINV - SCREENING", multiple = TRUE ), select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("SEX", "RACE", "COUNTRY", "ARM", "PARAMCD", "AVISIT")), + choices = variable_choices(data@env$ADRS, c("SEX", "RACE", "COUNTRY", "ARM", "PARAMCD", "AVISIT")), selected = "SEX", multiple = FALSE, fixed = FALSE @@ -230,7 +215,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("SEX", "RACE")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE")), selected = NULL, multiple = FALSE, fixed = FALSE @@ -240,7 +225,7 @@ app <- teal::init( color = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -250,7 +235,7 @@ app <- teal::init( fill = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -260,7 +245,7 @@ app <- teal::init( size = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -277,21 +262,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD)[1], + choices = value_choices(data@env$ADRS, "PARAMCD", "PARAM"), + selected = levels(data@env$ADRS$PARAMCD)[1], multiple = FALSE, label = "Select response:" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT)[1], + choices = levels(data@env$ADRS$AVISIT), + selected = levels(data@env$ADRS$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data@env$ADRS, c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE, label = "Select variable:" @@ -300,7 +285,7 @@ app <- teal::init( y = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("BMRKR1", "SEX", "AGE", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "SEX", "AGE", "RACE", "COUNTRY")), selected = "BMRKR1", multiple = FALSE, label = "Select variable:", @@ -310,7 +295,7 @@ app <- teal::init( row_facet = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("SEX", "RACE", "ARMCD", "PARAMCD")), + choices = variable_choices(data@env$ADRS, c("SEX", "RACE", "ARMCD", "PARAMCD")), selected = "SEX", multiple = FALSE, label = "Select variable:" @@ -319,7 +304,7 @@ app <- teal::init( col_facet = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("SEX", "RACE", "ARMCD", "PARAMCD", "AVISIT")), + choices = variable_choices(data@env$ADRS, c("SEX", "RACE", "ARMCD", "PARAMCD", "AVISIT")), selected = "ARMCD", multiple = FALSE, fixed = FALSE, @@ -334,21 +319,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD)[1], + choices = value_choices(data@env$ADRS, "PARAMCD", "PARAM"), + selected = levels(data@env$ADRS$PARAMCD)[1], multiple = FALSE, label = "Select response:" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT)[1], + choices = levels(data@env$ADRS$AVISIT), + selected = levels(data@env$ADRS$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data@env$ADRS, c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE, label = "Select variable:" @@ -357,7 +342,7 @@ app <- teal::init( y = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("BMRKR1", "SEX", "AGE", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "SEX", "AGE", "RACE", "COUNTRY")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE @@ -368,15 +353,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select measurement:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -392,7 +377,7 @@ app <- teal::init( col_facet = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "AGE", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "AGE", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -403,7 +388,7 @@ app <- teal::init( color = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -413,7 +398,7 @@ app <- teal::init( fill = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -423,7 +408,7 @@ app <- teal::init( size = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -438,7 +423,7 @@ app <- teal::init( x = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data@env$ADRS, c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -448,7 +433,7 @@ app <- teal::init( y = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("SEX", "RACE", "COUNTRY", "ARMCD", "BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADRS, c("SEX", "RACE", "COUNTRY", "ARMCD", "BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE, @@ -458,7 +443,7 @@ app <- teal::init( row_facet = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVISIT", "PARAMCD")), + choices = variable_choices(data@env$ADRS, c("AVISIT", "PARAMCD")), selected = "PARAMCD", multiple = FALSE, label = "Select variables:" @@ -467,7 +452,7 @@ app <- teal::init( col_facet = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVISIT", "PARAMCD")), + choices = variable_choices(data@env$ADRS, c("AVISIT", "PARAMCD")), selected = "AVISIT", multiple = FALSE, label = "Select variables:" @@ -481,15 +466,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -506,15 +491,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -532,21 +517,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select category:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("RACE", "SEX", "ARMCD", "ACTARMCD")), + choices = variable_choices(data@env$ADLB, c("RACE", "SEX", "ARMCD", "ACTARMCD")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -558,21 +543,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select category:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("RACE", "SEX", "ARMCD", "ACTARMCD")), + choices = variable_choices(data@env$ADLB, c("RACE", "SEX", "ARMCD", "ACTARMCD")), selected = "ARMCD", multiple = FALSE, fixed = FALSE, @@ -583,7 +568,7 @@ app <- teal::init( color = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -593,7 +578,7 @@ app <- teal::init( fill = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -603,7 +588,7 @@ app <- teal::init( size = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1")), selected = NULL, multiple = FALSE, fixed = FALSE, diff --git a/vignettes/using-cross-table.Rmd b/vignettes/using-cross-table.Rmd index 1af963d0f..d8cc65230 100644 --- a/vignettes/using-cross-table.Rmd +++ b/vignettes/using-cross-table.Rmd @@ -29,28 +29,25 @@ library(dplyr) # used to modify data sets ## Create data sets -Inside this app 5 datasets will be used +Inside this app 2 datasets will be used 1. `ADSL` A wide data set with subject data -2. `ADSL2` A wide data set with subject data -3. `ADRS` A long data set with response data for subjects at different time points of the study -4. `ADTTE` A long data set with time to event data -5. `ADLB` A long data set with lab measurements for each subject +2. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide", echo=2:6} -# nolint start -ADSL <- teal.modules.general::rADSL -ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) -ADRS <- teal.modules.general::rADRS -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ "N", - CHG > 1 ~ "P", - TRUE ~ "-" - ))) -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) ``` ## Create an `app` variable @@ -62,27 +59,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset( - "ADSL2", - ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset("ADLB", ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( modules( label = "Cross table", @@ -92,8 +69,8 @@ app <- teal::init( "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), - selected = names(ADSL)[5], + choices = variable_choices(data@env$ADSL), + selected = names(data@env$ADSL)[5], multiple = TRUE, fixed = FALSE, ordered = TRUE @@ -103,8 +80,8 @@ app <- teal::init( "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), - selected = names(ADSL)[6], + choices = variable_choices(data@env$ADSL), + selected = names(data@env$ADSL)[6], multiple = FALSE, fixed = FALSE ) @@ -116,12 +93,12 @@ app <- teal::init( dataname = "ADLB", filter = teal.transform::filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data@env$ADLB), selected = "AVISIT", multiple = TRUE, fixed = FALSE, @@ -133,12 +110,12 @@ app <- teal::init( dataname = "ADLB", filter = teal.transform::filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data@env$ADLB), selected = "LOQFL", multiple = FALSE, fixed = FALSE, diff --git a/vignettes/using-data-table.Rmd b/vignettes/using-data-table.Rmd index 8f012bb0e..92f842416 100644 --- a/vignettes/using-data-table.Rmd +++ b/vignettes/using-data-table.Rmd @@ -35,11 +35,15 @@ Inside this app 3 datasets will be used 3. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB +}) +datanames <- c("ADSL", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) ``` ## Create an `app` variable @@ -50,12 +54,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset("ADLB", ADLB, code = "ADLB <- teal.modules.general::rADLB"), - check = TRUE - ), + data = data, modules = teal::modules( # two-datasets example tm_data_table( diff --git a/vignettes/using-outliers-module.Rmd b/vignettes/using-outliers-module.Rmd index c7d4e6812..05abc5733 100644 --- a/vignettes/using-outliers-module.Rmd +++ b/vignettes/using-outliers-module.Rmd @@ -36,11 +36,15 @@ Inside this app 5 datasets will be used 3. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADRS <- teal.modules.general::rADRS -ADLB <- teal.modules.general::rADLB -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADRS <- teal.modules.general::rADRS + ADLB <- teal.modules.general::rADLB +}) +datanames <- c("ADSL", "ADRS", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) ``` ## Create an `app` variable @@ -52,12 +56,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADLB", ADLB, code = "ADLB <- teal.modules.general::rADLB"), - check = TRUE - ), + data = data, modules = teal::modules( # tm_outliers ---- modules( @@ -68,7 +67,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1")), selected = "AGE", fixed = FALSE ) @@ -77,7 +76,10 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, subset = names(Filter(isTRUE, sapply(ADSL, is.factor)))), + choices = variable_choices( + data@env$ADSL, + subset = names(Filter(isTRUE, sapply(data@env$ADSL, is.factor))) + ), selected = "RACE", multiple = FALSE, fixed = FALSE @@ -91,7 +93,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1")), selected = "AGE", fixed = FALSE ) @@ -100,7 +102,7 @@ app <- teal::init( dataname = "ADLB", select = select_spec( label = "Select variable:", - choices = variable_choices(ADLB, c("AVAL", "CHG2")), + choices = variable_choices(data@env$ADLB, c("AVAL", "CHG2")), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -112,7 +114,10 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, subset = names(Filter(isTRUE, sapply(ADSL, is.factor)))), + choices = variable_choices( + data@env$ADSL, + subset = names(Filter(isTRUE, sapply(data@env$ADSL, is.factor))) + ), selected = "RACE", multiple = FALSE, fixed = FALSE @@ -126,7 +131,7 @@ app <- teal::init( dataname = "ADRS", select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("ADY", "EOSDY")), + choices = variable_choices(data@env$ADRS, c("ADY", "EOSDY")), selected = "ADY", fixed = FALSE ) @@ -135,7 +140,7 @@ app <- teal::init( dataname = "ADLB", select = select_spec( label = "Select variable:", - choices = variable_choices(ADLB, c("AVAL", "CHG2")), + choices = variable_choices(data@env$ADLB, c("AVAL", "CHG2")), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -147,7 +152,7 @@ app <- teal::init( dataname = "ADRS", select = select_spec( label = "Select variables:", - choices = variable_choices(ADRS, c("ARM", "ACTARM")), + choices = variable_choices(data@env$ADRS, c("ARM", "ACTARM")), selected = "ARM", multiple = FALSE, fixed = FALSE @@ -157,7 +162,10 @@ app <- teal::init( dataname = "ADLB", select = select_spec( label = "Select variables:", - choices = variable_choices(ADLB, subset = names(Filter(isTRUE, sapply(ADLB, is.factor)))), + choices = variable_choices( + data@env$ADLB, + subset = names(Filter(isTRUE, sapply(data@env$ADLB, is.factor))) + ), selected = "RACE", multiple = FALSE, fixed = FALSE diff --git a/vignettes/using-regression-plots.Rmd b/vignettes/using-regression-plots.Rmd index ec4b54e9e..776cd423b 100644 --- a/vignettes/using-regression-plots.Rmd +++ b/vignettes/using-regression-plots.Rmd @@ -39,19 +39,26 @@ Inside this app 5 datasets will be used 5. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) -ADRS <- teal.modules.general::rADRS -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ "N", - CHG > 1 ~ "P", - TRUE ~ "-" - ))) -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADSL2 <- teal.modules.general::rADSL %>% + mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) + ADRS <- teal.modules.general::rADRS + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADSL2", "ADRS", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) +data@join_keys$mutate( + "ADSL2", "ADSL", get_cdisc_keys("ADSL") +) ``` ## Create an `app` variable @@ -63,27 +70,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset("ADSL2", ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset( - "ADLB", - ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( modules( label = "Regression plots", @@ -93,7 +80,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE @@ -103,7 +90,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("AGE", "SEX", "RACE")), + choices = variable_choices(data@env$ADSL, c("AGE", "SEX", "RACE")), selected = "AGE", multiple = TRUE, fixed = FALSE @@ -117,7 +104,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE @@ -127,7 +114,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE")), + choices = variable_choices(data@env$ADSL2, c("AGE", "SEX", "RACE")), selected = c("AGE", "RACE"), multiple = TRUE, fixed = FALSE @@ -141,7 +128,7 @@ app <- teal::init( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE, c("AVAL", "CNSR")), + choices = variable_choices(data@env$ADTTE, c("AVAL", "CNSR")), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -149,7 +136,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select parameter:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADTTE, "PARAMCD", "PARAM"), selected = "PFS", multiple = FALSE ) @@ -158,14 +145,14 @@ app <- teal::init( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE, c("AGE", "CNSR", "SEX")), + choices = variable_choices(data@env$ADTTE, c("AGE", "CNSR", "SEX")), selected = c("AGE", "CNSR", "SEX"), multiple = TRUE ), filter = teal.transform::filter_spec( label = "Select parameter:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADTTE, "PARAMCD", "PARAM"), selected = "PFS", multiple = FALSE ) @@ -178,15 +165,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[2], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[2], multiple = TRUE, label = "Select measurement:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[2], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[2], multiple = TRUE, label = "Select visit:" ) @@ -203,7 +190,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2", "AGE")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "BMRKR2", "AGE")), selected = "AGE", multiple = TRUE, fixed = FALSE @@ -218,15 +205,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = TRUE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = TRUE, label = "Select visit:" ) @@ -243,21 +230,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("AVAL", "AGE", "BMRKR1", "BMRKR2", "SEX", "ARM")), + choices = variable_choices(data@env$ADLB, c("AVAL", "AGE", "BMRKR1", "BMRKR2", "SEX", "ARM")), selected = c("AVAL", "BMRKR1"), multiple = TRUE ) diff --git a/vignettes/using-response-plot.Rmd b/vignettes/using-response-plot.Rmd index 3990a1cbc..698f5ca36 100644 --- a/vignettes/using-response-plot.Rmd +++ b/vignettes/using-response-plot.Rmd @@ -38,19 +38,26 @@ Inside this app 5 datasets will be used 5. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) -ADRS <- teal.modules.general::rADRS -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ "N", - CHG > 1 ~ "P", - TRUE ~ "-" - ))) -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADSL2 <- teal.modules.general::rADSL %>% + mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) + ADRS <- teal.modules.general::rADRS + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADSL2", "ADRS", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) +data@join_keys$mutate( + "ADSL2", "ADSL", get_cdisc_keys("ADSL") +) ``` ## Create an `app` variable @@ -62,29 +69,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset( - "ADSL2", - ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset( - "ADLB", - ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( modules( label = "Response plot", @@ -94,7 +79,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR2", "ITTFL", "BEP01FL")), + choices = variable_choices(data@env$ADSL, c("BMRKR2", "ITTFL", "BEP01FL")), selected = "BMRKR2", multiple = FALSE, fixed = FALSE @@ -104,7 +89,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY", "ARMCD", "STRATA1")), + choices = variable_choices(data@env$ADSL, c("SEX", "RACE", "COUNTRY", "ARMCD", "STRATA1")), selected = "ARMCD", multiple = FALSE, fixed = FALSE @@ -117,7 +102,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR2", "ITTFL", "BEP01FL")), + choices = variable_choices(data@env$ADSL, c("BMRKR2", "ITTFL", "BEP01FL")), selected = "BMRKR2", multiple = FALSE ) @@ -140,21 +125,21 @@ app <- teal::init( filter_spec( label = "Select parameter:", vars = "PARAMCD", - choices = levels(ADLB$PARAMCD), - selected = levels(ADLB$PARAMCD)[1], + choices = levels(data@env$ADLB$PARAMCD), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE ), filter_spec( label = "Select visit:", vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE ) ), select = select_spec( label = "Select variable:", - choices = variable_choices(ADLB, c("BMRKR2", "ITTFL", "BEP01FL")), + choices = variable_choices(data@env$ADLB, c("BMRKR2", "ITTFL", "BEP01FL")), selected = "BMRKR2", multiple = FALSE ) @@ -165,15 +150,15 @@ app <- teal::init( filter_spec( label = "Select parameter:", vars = "PARAMCD", - choices = levels(ADRS$PARAMCD), - selected = levels(ADRS$PARAMCD)[3], + choices = levels(data@env$ADRS$PARAMCD), + selected = levels(data@env$ADRS$PARAMCD)[3], multiple = FALSE ), filter_spec( label = "Select visit:", vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT)[3], + choices = levels(data@env$ADRS$AVISIT), + selected = levels(data@env$ADRS$AVISIT)[3], multiple = FALSE ) ), @@ -197,7 +182,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("SEX", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "COUNTRY")), selected = NULL, multiple = FALSE ) @@ -210,21 +195,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = levels(ADLB$PARAMCD), - selected = levels(ADLB$PARAMCD)[2], + choices = levels(data@env$ADLB$PARAMCD), + selected = levels(data@env$ADLB$PARAMCD)[2], multiple = TRUE, label = "Select measurement:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[2], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[2], multiple = TRUE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("BMRKR2", "ITTFL", "BEP01FL")), + choices = variable_choices(data@env$ADLB, c("BMRKR2", "ITTFL", "BEP01FL")), selected = "BMRKR2", multiple = FALSE, fixed = FALSE, @@ -234,7 +219,7 @@ app <- teal::init( x = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("ARMCD", "BMRKR1", "BMRKR2", "BEP01FL")), + choices = variable_choices(data@env$ADSL, c("ARMCD", "BMRKR1", "BMRKR2", "BEP01FL")), selected = "BMRKR2", multiple = FALSE, fixed = FALSE @@ -246,7 +231,7 @@ app <- teal::init( response = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("BMRKR2", "AVALC", "BEP01FL")), + choices = variable_choices(data@env$ADRS, c("BMRKR2", "AVALC", "BEP01FL")), selected = "AVALC", multiple = FALSE, fixed = TRUE, @@ -256,7 +241,7 @@ app <- teal::init( x = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AGE", "SEX", "ARMCD", "STRATA1")), + choices = variable_choices(data@env$ADRS, c("AVALC", "AGE", "SEX", "ARMCD", "STRATA1")), selected = "ARMCD", multiple = FALSE, fixed = FALSE, @@ -290,8 +275,8 @@ app <- teal::init( dataname = "ADLB", filter = teal.transform::filter_spec( vars = "PARAMCD", - choices = levels(ADLB$PARAMCD), - selected = levels(ADLB$PARAMCD)[2], + choices = levels(data@env$ADLB$PARAMCD), + selected = levels(data@env$ADLB$PARAMCD)[2], multiple = FALSE, label = "Select lab:" ), @@ -306,13 +291,13 @@ app <- teal::init( dataname = "ADLB", filter = teal.transform::filter_spec( vars = "PARAMCD", - choices = levels(ADLB$PARAMCD), - selected = levels(ADLB$PARAMCD)[1], + choices = levels(data@env$ADLB$PARAMCD), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), select = select_spec( - choices = variable_choices(ADLB, c("AVISIT", "PARAMCD", "BEP01FL")), + choices = variable_choices(data@env$ADLB, c("AVISIT", "PARAMCD", "BEP01FL")), selected = "AVISIT", multiple = FALSE, fixed = TRUE @@ -323,21 +308,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = levels(ADLB$PARAMCD), - selected = levels(ADLB$PARAMCD)[1], + choices = levels(data@env$ADLB$PARAMCD), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("SEX", "RACE", "ARMCD")), + choices = variable_choices(data@env$ADLB, c("SEX", "RACE", "ARMCD")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -349,21 +334,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = levels(ADLB$PARAMCD), - selected = levels(ADLB$PARAMCD)[1], + choices = levels(data@env$ADLB$PARAMCD), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("SEX", "RACE", "ARMCD")), + choices = variable_choices(data@env$ADLB, c("SEX", "RACE", "ARMCD")), selected = NULL, multiple = FALSE, fixed = FALSE, diff --git a/vignettes/using-scatterplot-matrix.Rmd b/vignettes/using-scatterplot-matrix.Rmd index 5833ffb95..21d14c530 100644 --- a/vignettes/using-scatterplot-matrix.Rmd +++ b/vignettes/using-scatterplot-matrix.Rmd @@ -39,19 +39,26 @@ Inside this app 5 datasets will be used 5. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) -ADRS <- teal.modules.general::rADRS -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ "N", - CHG > 1 ~ "P", - TRUE ~ "-" - ))) -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADSL2 <- teal.modules.general::rADSL %>% + mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) + ADRS <- teal.modules.general::rADRS + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADSL2", "ADRS", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) +data@join_keys$mutate( + "ADSL2", "ADSL", get_cdisc_keys("ADSL") +) ``` ## Create an `app` variable @@ -63,27 +70,7 @@ combinations of data sets. ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset( - "ADSL2", - ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset("ADLB", ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( modules( label = "Scatterplot matrix", @@ -94,7 +81,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = c("AGE", "RACE", "SEX", "BMRKR1", "BMRKR2"), multiple = TRUE, fixed = FALSE, @@ -109,7 +96,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data@env$ADSL), selected = c("AGE", "ACTARM", "SEX", "BMRKR1"), multiple = TRUE, fixed = FALSE, @@ -120,7 +107,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2), + choices = variable_choices(data@env$ADSL2), selected = c("COUNTRY", "ACTARM", "STRATA1"), multiple = TRUE, fixed = FALSE, @@ -134,7 +121,7 @@ app <- teal::init( variables = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( - choices = variable_choices(ADTTE, c("AVAL", "BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADTTE, c("AVAL", "BMRKR1", "BMRKR2")), selected = c("AVAL", "BMRKR1", "BMRKR2"), multiple = TRUE, fixed = FALSE, @@ -150,7 +137,7 @@ app <- teal::init( dataname = "ADRS", select = select_spec( label = "Select variables:", - choices = variable_choices(ADRS), + choices = variable_choices(data@env$ADRS), selected = c("AVAL", "AVALC"), multiple = TRUE, fixed = FALSE, @@ -159,7 +146,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select endpoints:", vars = c("PARAMCD", "AVISIT"), - choices = value_choices(ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), + choices = value_choices(data@env$ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), selected = "OVRINV - SCREENING", multiple = FALSE ) @@ -168,7 +155,7 @@ app <- teal::init( dataname = "ADTTE", select = select_spec( label = "Select variables:", - choices = variable_choices(ADTTE), + choices = variable_choices(data@env$ADTTE), selected = c("AVAL", "CNSR"), multiple = TRUE, fixed = FALSE, @@ -177,7 +164,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select parameters:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADTTE, "PARAMCD", "PARAM"), selected = "OS", multiple = TRUE ) diff --git a/vignettes/using-scatterplot.Rmd b/vignettes/using-scatterplot.Rmd index a9c24939f..344bc45fa 100644 --- a/vignettes/using-scatterplot.Rmd +++ b/vignettes/using-scatterplot.Rmd @@ -39,19 +39,26 @@ Inside this app 5 datasets will be used 5. `ADLB` A long data set with lab measurements for each subject ```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"} -# nolint start -ADSL <- teal.modules.general::rADSL -ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) -ADRS <- teal.modules.general::rADRS -ADTTE <- teal.modules.general::rADTTE -ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ "N", - CHG > 1 ~ "P", - TRUE ~ "-" - ))) -# nolint end +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADSL2 <- teal.modules.general::rADSL %>% + mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1)) + ADRS <- teal.modules.general::rADRS + ADTTE <- teal.modules.general::rADTTE + ADLB <- teal.modules.general::rADLB %>% + mutate(CHGC = as.factor(case_when( + CHG < 1 ~ "N", + CHG > 1 ~ "P", + TRUE ~ "-" + ))) +}) +datanames <- c("ADSL", "ADSL2", "ADRS", "ADTTE", "ADLB") +datanames(data) <- datanames +data@join_keys <- cdisc_join_keys(!!!datanames) +data@join_keys$mutate( + "ADSL2", "ADSL", get_cdisc_keys("ADSL") +) ``` ## Create an `app` variable @@ -69,27 +76,7 @@ ggextra_available <- requireNamespace("ggExtra", quietly = TRUE) ``` ```{r, eval = ggextra_available, echo=TRUE, message=FALSE, warning=FALSE, results="hide"} app <- teal::init( - data = teal.data::cdisc_data( - teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"), - teal.data::cdisc_dataset( - "ADSL2", - ADSL2, - keys = get_cdisc_keys("ADSL"), - code = "ADSL2 <- teal.modules.general::rADSL %>% - mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))" - ), - teal.data::cdisc_dataset("ADRS", ADRS, code = "ADRS <- teal.modules.general::rADRS"), - teal.data::cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- teal.modules.general::rADTTE"), - teal.data::cdisc_dataset("ADLB", ADLB, - code = "ADLB <- teal.modules.general::rADLB %>% - mutate(CHGC = as.factor(case_when( - CHG < 1 ~ 'N', - CHG > 1 ~ 'P', - TRUE ~ '-' - )))" - ), - check = TRUE - ), + data = data, modules = teal::modules( modules( label = "Scatterplot", @@ -99,7 +86,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1", "BMRKR2")), selected = "AGE", multiple = FALSE, fixed = FALSE @@ -109,7 +96,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADSL, c("AGE", "BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE @@ -119,7 +106,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("RACE", "SEX")), + choices = variable_choices(data@env$ADSL, c("RACE", "SEX")), selected = NULL, multiple = TRUE, fixed = FALSE @@ -133,7 +120,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADSL, c("BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE @@ -143,7 +130,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL2, c("AGE", "SEX")), + choices = variable_choices(data@env$ADSL2, c("AGE", "SEX")), selected = "AGE", multiple = FALSE, fixed = FALSE @@ -153,7 +140,7 @@ app <- teal::init( dataname = "ADSL2", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL2, c("COUNTRY", "AGE", "RACE")), + choices = variable_choices(data@env$ADSL2, c("COUNTRY", "AGE", "RACE")), selected = "COUNTRY", multiple = FALSE, fixed = FALSE @@ -166,7 +153,7 @@ app <- teal::init( dataname = "ADRS", select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS), + choices = variable_choices(data@env$ADRS), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -174,7 +161,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select endpoint:", vars = c("PARAMCD", "AVISIT"), - choices = value_choices(ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), + choices = value_choices(data@env$ADRS, c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), selected = "OVRINV - SCREENING", multiple = FALSE ) @@ -183,7 +170,7 @@ app <- teal::init( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE), + choices = variable_choices(data@env$ADTTE), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -191,7 +178,7 @@ app <- teal::init( filter = teal.transform::filter_spec( label = "Select parameters:", vars = c("PARAMCD"), - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data@env$ADTTE, "PARAMCD", "PARAM"), selected = "OS", multiple = TRUE ) @@ -200,7 +187,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "SEX")), + choices = variable_choices(data@env$ADSL, c("AGE", "SEX")), selected = "AGE", multiple = FALSE, fixed = FALSE @@ -213,7 +200,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("SEX", "AGE", "BMRKR1", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "AGE", "BMRKR1", "COUNTRY")), selected = "AGE", multiple = FALSE, fixed = FALSE @@ -224,15 +211,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select measurement:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -249,7 +236,7 @@ app <- teal::init( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("SEX", "AGE", "RACE", "COUNTRY")), + choices = variable_choices(data@env$ADSL, c("SEX", "AGE", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE @@ -261,7 +248,7 @@ app <- teal::init( x = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADRS, c("AVAL", "BMRKR1", "BMRKR2")), selected = "AVAL", multiple = FALSE, fixed = FALSE, @@ -271,7 +258,7 @@ app <- teal::init( y = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "BMRKR1", "BMRKR2")), + choices = variable_choices(data@env$ADRS, c("AVAL", "BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE, @@ -281,7 +268,7 @@ app <- teal::init( color_by = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AGE", "SEX", "RACE")), + choices = variable_choices(data@env$ADRS, c("AGE", "SEX", "RACE")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -296,15 +283,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -321,15 +308,15 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -346,21 +333,21 @@ app <- teal::init( filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data@env$ADLB, "PARAMCD", "PARAM"), + selected = levels(data@env$ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data@env$ADLB$AVISIT), + selected = levels(data@env$ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("RACE", "SEX")), + choices = variable_choices(data@env$ADLB, c("RACE", "SEX")), selected = "SEX", multiple = FALSE, fixed = FALSE,