diff --git a/main/404.html b/main/404.html index ed94cde46..9074a9890 100644 --- a/main/404.html +++ b/main/404.html @@ -25,7 +25,7 @@ teal.modules.general - 0.2.16.9007 + 0.2.16.9010
library(teal.modules.general) -ADSL <- teal.modules.general::rADSL # nolint -ADTTE <- teal.modules.general::rADTTE # nolint +# nolint start +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADTTE <- teal.modules.general::rADTTE +}) +datanames <- c("ADSL", "ADTTE") +datanames(data) <- datanames +join_keys(data) <- default_cdisc_join_keys[datanames] +# nolint end 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", @@ -185,9 +180,26 @@ Example applicationlibrary(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.
teal_data
Following this, we set the datanames and +join_keys.
datanames
join_keys
-ADSL <- teal.modules.general::rADSL -ADAE <- teal.modules.general::rADAE
ADSL <- teal.modules.general::rADSL -ADAE <- teal.modules.general::rADAE
# nolint start +data <- teal_data() +data <- within(data, { + ADSL <- teal.modules.general::rADSL + ADTTE <- teal.modules.general::rADTTE +}) +datanames <- c("ADSL", "ADTTE") +datanames(data) <- datanames +join_keys(data) <- default_cdisc_join_keys[datanames] +# nolint end
There is no need to load teal as teal.modules.general already depends on it.
teal
teal.modules.general
In the next step, we use teal to create @@ -199,11 +211,7 @@
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/main/articles/using-association-plot.html b/main/articles/using-association-plot.html index be782839e..196634f09 100644 --- a/main/articles/using-association-plot.html +++ b/main/articles/using-association-plot.html @@ -27,7 +27,7 @@ teal.modules.general - 0.2.16.9007 + 0.2.16.9010 part of @@ -59,15 +59,6 @@ Changelog - - Versions main -latest-tag -v0.2.16 -v0.2.15 - Reports @@ -103,7 +94,7 @@ Dawid Kałędkowski - 2023-09-14 + 2023-11-20 using-association-plot.Rmd @@ -173,50 +164,53 @@ Create an app variabletm_g_association using different combinations of data sets. -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 - ), +# nolint start +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 +jk <- default_cdisc_join_keys[datanames] +jk_adsl2 <- jk +names(jk_adsl2)[names(jk_adsl2) == "ADSL"] <- "ADSL2" +jk <- c(jk, jk_adsl2) +jk["ADSL2", "ADSL"] <- c("USUBJID", "STUDYID") + +# nolint end + +app <- teal::init( + data = data, modules = teal::modules( # tm_g_association ---- modules( label = "Association plot", tm_g_association( label = "Single wide dataset", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "AGE", fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "BMRKR1", multiple = TRUE, fixed = FALSE @@ -225,21 +219,21 @@ Create an app variable ), tm_g_association( label = "Two wide datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "STRATA1", "RACE")), selected = "STRATA1", multiple = FALSE, fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL2"]], c("AGE", "SEX", "RACE", "COUNTRY")), selected = c("AGE", "COUNTRY", "RACE"), multiple = TRUE, fixed = FALSE @@ -248,29 +242,29 @@ Create an app variable ), tm_g_association( label = "Multiple different long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variables:", - choices = variable_choices(ADTTE), + choices = variable_choices(data[["ADTTE"]]), selected = "AVAL", multiple = FALSE, fixed = FALSE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select endpoint:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = c("PFS", "EFS"), multiple = TRUE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", reshape = TRUE, select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("AVALC", "BMRKR1", "BMRKR2", "ARM")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "BMRKR1", "BMRKR2", "ARM")), selected = "AVALC", multiple = TRUE, fixed = FALSE @@ -279,14 +273,14 @@ Create an app variable filter_spec( label = "Select endpoints:", vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), selected = "BESRSPI", multiple = TRUE ), filter_spec( label = "Select endpoints:", vars = "AVISIT", - choices = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), selected = "SCREENING", multiple = TRUE ) @@ -295,10 +289,10 @@ Create an app variable ), tm_g_association( label = "Wide and long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "AVALC")), + choices = variable_choices(data[["ADRS"]], c("AVAL", "AVALC")), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -307,24 +301,24 @@ Create an app variable filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADRS"]]$PARAMCD), multiple = TRUE, label = "Select response" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), + selected = levels(data[["ADRS"]]$AVISIT), multiple = TRUE, label = "Select visit:" ) ) ), - vars = teal.transform::data_extract_spec( + 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[["ADSL"]], c("SEX", "AGE", "RACE", "COUNTRY", "BMRKR1", "STRATA1", "ARM")), selected = "AGE", multiple = TRUE, fixed = FALSE, @@ -334,20 +328,20 @@ Create an app variable ), tm_g_association( label = "Same long datasets (same subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "AVALC", multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "PARAMCD", multiple = TRUE, fixed = FALSE, @@ -357,50 +351,50 @@ Create an app variable ), tm_g_association( label = "Same long datasets (different subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("AVAL", "CHG2", "PCHG2")), + choices = variable_choices(data[["ADLB"]], c("AVAL", "CHG2", "PCHG2")), selected = "AVAL", multiple = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data[["ADLB"]]), selected = "STRATA1", multiple = TRUE ) @@ -418,7 +412,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
using-association-plot.Rmd
app
-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 - ), +# nolint start +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 +jk <- default_cdisc_join_keys[datanames] +jk_adsl2 <- jk +names(jk_adsl2)[names(jk_adsl2) == "ADSL"] <- "ADSL2" +jk <- c(jk, jk_adsl2) +jk["ADSL2", "ADSL"] <- c("USUBJID", "STUDYID") + +# nolint end + +app <- teal::init( + data = data, modules = teal::modules( # tm_g_association ---- modules( label = "Association plot", tm_g_association( label = "Single wide dataset", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "AGE", fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "BMRKR1", multiple = TRUE, fixed = FALSE @@ -225,21 +219,21 @@ Create an app variable ), tm_g_association( label = "Two wide datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "STRATA1", "RACE")), selected = "STRATA1", multiple = FALSE, fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL2"]], c("AGE", "SEX", "RACE", "COUNTRY")), selected = c("AGE", "COUNTRY", "RACE"), multiple = TRUE, fixed = FALSE @@ -248,29 +242,29 @@ Create an app variable ), tm_g_association( label = "Multiple different long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variables:", - choices = variable_choices(ADTTE), + choices = variable_choices(data[["ADTTE"]]), selected = "AVAL", multiple = FALSE, fixed = FALSE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select endpoint:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = c("PFS", "EFS"), multiple = TRUE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", reshape = TRUE, select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("AVALC", "BMRKR1", "BMRKR2", "ARM")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "BMRKR1", "BMRKR2", "ARM")), selected = "AVALC", multiple = TRUE, fixed = FALSE @@ -279,14 +273,14 @@ Create an app variable filter_spec( label = "Select endpoints:", vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), selected = "BESRSPI", multiple = TRUE ), filter_spec( label = "Select endpoints:", vars = "AVISIT", - choices = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), selected = "SCREENING", multiple = TRUE ) @@ -295,10 +289,10 @@ Create an app variable ), tm_g_association( label = "Wide and long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "AVALC")), + choices = variable_choices(data[["ADRS"]], c("AVAL", "AVALC")), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -307,24 +301,24 @@ Create an app variable filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADRS"]]$PARAMCD), multiple = TRUE, label = "Select response" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), + selected = levels(data[["ADRS"]]$AVISIT), multiple = TRUE, label = "Select visit:" ) ) ), - vars = teal.transform::data_extract_spec( + 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[["ADSL"]], c("SEX", "AGE", "RACE", "COUNTRY", "BMRKR1", "STRATA1", "ARM")), selected = "AGE", multiple = TRUE, fixed = FALSE, @@ -334,20 +328,20 @@ Create an app variable ), tm_g_association( label = "Same long datasets (same subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "AVALC", multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "PARAMCD", multiple = TRUE, fixed = FALSE, @@ -357,50 +351,50 @@ Create an app variable ), tm_g_association( label = "Same long datasets (different subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("AVAL", "CHG2", "PCHG2")), + choices = variable_choices(data[["ADLB"]], c("AVAL", "CHG2", "PCHG2")), selected = "AVAL", multiple = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data[["ADLB"]]), selected = "STRATA1", multiple = TRUE ) @@ -418,7 +412,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
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 - ), +# nolint start +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 +jk <- default_cdisc_join_keys[datanames] +jk_adsl2 <- jk +names(jk_adsl2)[names(jk_adsl2) == "ADSL"] <- "ADSL2" +jk <- c(jk, jk_adsl2) +jk["ADSL2", "ADSL"] <- c("USUBJID", "STUDYID") + +# nolint end + +app <- teal::init( + data = data, modules = teal::modules( # tm_g_association ---- modules( label = "Association plot", tm_g_association( label = "Single wide dataset", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "AGE", fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "BMRKR1", multiple = TRUE, fixed = FALSE @@ -225,21 +219,21 @@ Create an app variable ), tm_g_association( label = "Two wide datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "STRATA1", "RACE")), selected = "STRATA1", multiple = FALSE, fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL2"]], c("AGE", "SEX", "RACE", "COUNTRY")), selected = c("AGE", "COUNTRY", "RACE"), multiple = TRUE, fixed = FALSE @@ -248,29 +242,29 @@ Create an app variable ), tm_g_association( label = "Multiple different long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variables:", - choices = variable_choices(ADTTE), + choices = variable_choices(data[["ADTTE"]]), selected = "AVAL", multiple = FALSE, fixed = FALSE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select endpoint:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = c("PFS", "EFS"), multiple = TRUE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", reshape = TRUE, select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("AVALC", "BMRKR1", "BMRKR2", "ARM")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "BMRKR1", "BMRKR2", "ARM")), selected = "AVALC", multiple = TRUE, fixed = FALSE @@ -279,14 +273,14 @@ Create an app variable filter_spec( label = "Select endpoints:", vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), selected = "BESRSPI", multiple = TRUE ), filter_spec( label = "Select endpoints:", vars = "AVISIT", - choices = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), selected = "SCREENING", multiple = TRUE ) @@ -295,10 +289,10 @@ Create an app variable ), tm_g_association( label = "Wide and long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "AVALC")), + choices = variable_choices(data[["ADRS"]], c("AVAL", "AVALC")), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -307,24 +301,24 @@ Create an app variable filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADRS"]]$PARAMCD), multiple = TRUE, label = "Select response" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), + selected = levels(data[["ADRS"]]$AVISIT), multiple = TRUE, label = "Select visit:" ) ) ), - vars = teal.transform::data_extract_spec( + 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[["ADSL"]], c("SEX", "AGE", "RACE", "COUNTRY", "BMRKR1", "STRATA1", "ARM")), selected = "AGE", multiple = TRUE, fixed = FALSE, @@ -334,20 +328,20 @@ Create an app variable ), tm_g_association( label = "Same long datasets (same subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "AVALC", multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "PARAMCD", multiple = TRUE, fixed = FALSE, @@ -357,50 +351,50 @@ Create an app variable ), tm_g_association( label = "Same long datasets (different subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("AVAL", "CHG2", "PCHG2")), + choices = variable_choices(data[["ADLB"]], c("AVAL", "CHG2", "PCHG2")), selected = "AVAL", multiple = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data[["ADLB"]]), selected = "STRATA1", multiple = TRUE ) @@ -418,7 +412,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
# nolint start +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 +jk <- default_cdisc_join_keys[datanames] +jk_adsl2 <- jk +names(jk_adsl2)[names(jk_adsl2) == "ADSL"] <- "ADSL2" +jk <- c(jk, jk_adsl2) +jk["ADSL2", "ADSL"] <- c("USUBJID", "STUDYID") + +# nolint end + +app <- teal::init( + data = data, modules = teal::modules( # tm_g_association ---- modules( label = "Association plot", tm_g_association( label = "Single wide dataset", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "AGE", fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "BMRKR1", multiple = TRUE, fixed = FALSE @@ -225,21 +219,21 @@ Create an app variable ), tm_g_association( label = "Two wide datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "STRATA1", "RACE")), selected = "STRATA1", multiple = FALSE, fixed = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL2"]], c("AGE", "SEX", "RACE", "COUNTRY")), selected = c("AGE", "COUNTRY", "RACE"), multiple = TRUE, fixed = FALSE @@ -248,29 +242,29 @@ Create an app variable ), tm_g_association( label = "Multiple different long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variables:", - choices = variable_choices(ADTTE), + choices = variable_choices(data[["ADTTE"]]), selected = "AVAL", multiple = FALSE, fixed = FALSE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select endpoint:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = c("PFS", "EFS"), multiple = TRUE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", reshape = TRUE, select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("AVALC", "BMRKR1", "BMRKR2", "ARM")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "BMRKR1", "BMRKR2", "ARM")), selected = "AVALC", multiple = TRUE, fixed = FALSE @@ -279,14 +273,14 @@ Create an app variable filter_spec( label = "Select endpoints:", vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), selected = "BESRSPI", multiple = TRUE ), filter_spec( label = "Select endpoints:", vars = "AVISIT", - choices = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), selected = "SCREENING", multiple = TRUE ) @@ -295,10 +289,10 @@ Create an app variable ), tm_g_association( label = "Wide and long datasets", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVAL", "AVALC")), + choices = variable_choices(data[["ADRS"]], c("AVAL", "AVALC")), selected = "AVALC", multiple = FALSE, fixed = FALSE, @@ -307,24 +301,24 @@ Create an app variable filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD), + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADRS"]]$PARAMCD), multiple = TRUE, label = "Select response" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT), + choices = levels(data[["ADRS"]]$AVISIT), + selected = levels(data[["ADRS"]]$AVISIT), multiple = TRUE, label = "Select visit:" ) ) ), - vars = teal.transform::data_extract_spec( + 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[["ADSL"]], c("SEX", "AGE", "RACE", "COUNTRY", "BMRKR1", "STRATA1", "ARM")), selected = "AGE", multiple = TRUE, fixed = FALSE, @@ -334,20 +328,20 @@ Create an app variable ), tm_g_association( label = "Same long datasets (same subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "AVALC", multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS), + choices = variable_choices(data[["ADRS"]]), selected = "PARAMCD", multiple = TRUE, fixed = FALSE, @@ -357,50 +351,50 @@ Create an app variable ), tm_g_association( label = "Same long datasets (different subsets)", - ref = teal.transform::data_extract_spec( + ref = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("AVAL", "CHG2", "PCHG2")), + choices = variable_choices(data[["ADLB"]], c("AVAL", "CHG2", "PCHG2")), selected = "AVAL", multiple = FALSE ) ), - vars = teal.transform::data_extract_spec( + vars = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data[["ADLB"]]), selected = "STRATA1", multiple = TRUE ) @@ -418,7 +412,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024))
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( label = "Bivariate plot", tm_g_bivariate( label = "Single wide dataset", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "BMRKR1", fixed = FALSE ) ), - y = teal.transform::data_extract_spec( + y = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = "SEX", multiple = FALSE, fixed = FALSE ) ), - row_facet = teal.transform::data_extract_spec( + row_facet = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = NULL, multiple = FALSE, fixed = FALSE ) ), - col_facet = teal.transform::data_extract_spec( + col_facet = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = NULL, multiple = FALSE, fixed = FALSE @@ -245,39 +224,39 @@ Create an app variable ), tm_g_bivariate( label = "Two wide datasets", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "AGE", "SEX", "STRATA1", "RACE")), + choices = variable_choices(data[["ADSL"]], c("BMRKR1", "AGE", "SEX", "STRATA1", "RACE")), selected = c("BMRKR1"), multiple = FALSE ) ), - y = teal.transform::data_extract_spec( + y = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("COUNTRY", "AGE", "RACE")), + choices = variable_choices(data[["ADSL2"]], c("COUNTRY", "AGE", "RACE")), selected = "RACE", multiple = FALSE ) ), - row_facet = teal.transform::data_extract_spec( + row_facet = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), + choices = variable_choices(data[["ADSL"]]), selected = NULL, multiple = FALSE, fixed = FALSE ) ), - col_facet = teal.transform::data_extract_spec( + col_facet = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2), + choices = variable_choices(data[["ADSL2"]]), selected = NULL, multiple = FALSE, fixed = FALSE @@ -286,90 +265,90 @@ Create an app variable ), tm_g_bivariate( label = "Multiple different long datasets", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADRS", - filter = teal.transform::filter_spec( + 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[["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[["ADRS"]], c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE ) ), - y = teal.transform::data_extract_spec( + y = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE, c("AVAL", "CNSR")), + choices = variable_choices(data[["ADTTE"]], c("AVAL", "CNSR")), selected = "AVAL", multiple = FALSE, fixed = FALSE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select endpoint:", vars = c("PARAMCD"), - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = "OS", multiple = FALSE ) ), - row_facet = teal.transform::data_extract_spec( + row_facet = teal.transform::data_extract_spec( dataname = "ADRS", - filter = teal.transform::filter_spec( + 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[["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[["ADRS"]], c("SEX", "RACE", "COUNTRY", "ARM", "PARAMCD", "AVISIT")), selected = "SEX", multiple = FALSE, fixed = FALSE ) ), - col_facet = teal.transform::data_extract_spec( + col_facet = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("SEX", "RACE")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE")), selected = NULL, multiple = FALSE, fixed = FALSE ) ), color_settings = TRUE, - color = teal.transform::data_extract_spec( + color = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - fill = teal.transform::data_extract_spec( + fill = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - size = teal.transform::data_extract_spec( + size = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -381,54 +360,54 @@ Create an app variable ), tm_g_bivariate( label = "Wide and long datasets", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADRS", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD)[1], + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADRS"]]$PARAMCD)[1], multiple = FALSE, label = "Select response:" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT)[1], + choices = levels(data[["ADRS"]]$AVISIT), + selected = levels(data[["ADRS"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE, label = "Select variable:" ) ), - y = teal.transform::data_extract_spec( + 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[["ADSL"]], c("BMRKR1", "SEX", "AGE", "RACE", "COUNTRY")), selected = "BMRKR1", multiple = FALSE, label = "Select variable:", fixed = FALSE ) ), - row_facet = teal.transform::data_extract_spec( + 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[["ADRS"]], c("SEX", "RACE", "ARMCD", "PARAMCD")), selected = "SEX", multiple = FALSE, label = "Select variable:" ) ), - col_facet = teal.transform::data_extract_spec( + 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[["ADRS"]], c("SEX", "RACE", "ARMCD", "PARAMCD", "AVISIT")), selected = "ARMCD", multiple = FALSE, fixed = FALSE, @@ -438,54 +417,54 @@ Create an app variable ), tm_g_bivariate( label = "Wide and multiple long datasets", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADRS", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADRS, "PARAMCD", "PARAM"), - selected = levels(ADRS$PARAMCD)[1], + choices = value_choices(data[["ADRS"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADRS"]]$PARAMCD)[1], multiple = FALSE, label = "Select response:" ), filter_spec( vars = "AVISIT", - choices = levels(ADRS$AVISIT), - selected = levels(ADRS$AVISIT)[1], + choices = levels(data[["ADRS"]]$AVISIT), + selected = levels(data[["ADRS"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE, label = "Select variable:" ) ), - y = teal.transform::data_extract_spec( + 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[["ADSL"]], c("BMRKR1", "SEX", "AGE", "RACE", "COUNTRY")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), - row_facet = teal.transform::data_extract_spec( + row_facet = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select measurement:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -498,10 +477,10 @@ Create an app variable label = "Select variable:" ) ), - col_facet = teal.transform::data_extract_spec( + 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[["ADSL"]], c("SEX", "AGE", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -509,30 +488,30 @@ Create an app variable ) ), color_settings = TRUE, - color = teal.transform::data_extract_spec( + color = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - fill = teal.transform::data_extract_spec( + fill = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - size = teal.transform::data_extract_spec( + size = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -544,39 +523,39 @@ Create an app variable ), tm_g_bivariate( label = "Same long datasets (same subset)", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVALC", "AVAL")), + choices = variable_choices(data[["ADRS"]], c("AVALC", "AVAL")), selected = "AVALC", multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - y = teal.transform::data_extract_spec( + 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[["ADRS"]], c("SEX", "RACE", "COUNTRY", "ARMCD", "BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - row_facet = teal.transform::data_extract_spec( + row_facet = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVISIT", "PARAMCD")), + choices = variable_choices(data[["ADRS"]], c("AVISIT", "PARAMCD")), selected = "PARAMCD", multiple = FALSE, label = "Select variables:" ) ), - col_facet = teal.transform::data_extract_spec( + col_facet = teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( - choices = variable_choices(ADRS, c("AVISIT", "PARAMCD")), + choices = variable_choices(data[["ADRS"]], c("AVISIT", "PARAMCD")), selected = "AVISIT", multiple = FALSE, label = "Select variables:" @@ -585,20 +564,20 @@ Create an app variable ), tm_g_bivariate( label = "Same datasets (different subsets)", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -610,20 +589,20 @@ Create an app variable fixed = TRUE ) ), - y = teal.transform::data_extract_spec( + y = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) @@ -636,52 +615,52 @@ Create an app variable ) ), use_density = FALSE, - row_facet = teal.transform::data_extract_spec( + row_facet = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select category:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("RACE", "SEX", "ARMCD", "ACTARMCD")), + choices = variable_choices(data[["ADLB"]], c("RACE", "SEX", "ARMCD", "ACTARMCD")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - col_facet = teal.transform::data_extract_spec( + col_facet = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = FALSE, label = "Select category:" ) ), select = select_spec( - choices = variable_choices(ADLB, c("RACE", "SEX", "ARMCD", "ACTARMCD")), + choices = variable_choices(data[["ADLB"]], c("RACE", "SEX", "ARMCD", "ACTARMCD")), selected = "ARMCD", multiple = FALSE, fixed = FALSE, @@ -689,30 +668,30 @@ Create an app variable ) ), color_settings = TRUE, - color = teal.transform::data_extract_spec( + color = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - fill = teal.transform::data_extract_spec( + fill = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("SEX", "RACE", "COUNTRY")), + choices = variable_choices(data[["ADSL"]], c("SEX", "RACE", "COUNTRY")), selected = NULL, multiple = FALSE, fixed = FALSE, label = "Select variable:" ) ), - size = teal.transform::data_extract_spec( + size = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = NULL, multiple = FALSE, fixed = FALSE, @@ -734,7 +713,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
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", tm_t_crosstable( label = "Single wide dataset", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), - selected = names(ADSL)[5], + choices = variable_choices(data[["ADSL"]]), + selected = names(data[["ADSL"]])[5], multiple = TRUE, fixed = FALSE, ordered = TRUE ) ), - y = teal.transform::data_extract_spec( + y = teal.transform::data_extract_spec( "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL), - selected = names(ADSL)[6], + choices = variable_choices(data[["ADSL"]]), + selected = names(data[["ADSL"]])[6], multiple = FALSE, fixed = FALSE ) @@ -221,16 +187,16 @@ Create an app variable ), tm_t_crosstable( label = "Same long datasets (different subsets)", - x = teal.transform::data_extract_spec( + x = teal.transform::data_extract_spec( dataname = "ADLB", - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data[["ADLB"]]), selected = "AVISIT", multiple = TRUE, fixed = FALSE, @@ -238,16 +204,16 @@ Create an app variable label = "Select variable:" ) ), - y = teal.transform::data_extract_spec( + y = teal.transform::data_extract_spec( dataname = "ADLB", - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE ), select = select_spec( - choices = variable_choices(ADLB), + choices = variable_choices(data[["ADLB"]]), selected = "LOQFL", multiple = FALSE, fixed = FALSE, @@ -267,7 +233,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
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( @@ -216,7 +208,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
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( label = "Outliers module", tm_outliers( label = "Single wide dataset", - outlier_var = teal.transform::data_extract_spec( + outlier_var = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = "AGE", fixed = FALSE ) ), - categorical_var = teal.transform::data_extract_spec( + categorical_var = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, subset = names(Filter(isTRUE, sapply(ADSL, is.factor)))), + choices = variable_choices( + data[["ADSL"]], + subset = names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor))) + ), selected = "RACE", multiple = FALSE, fixed = FALSE @@ -196,20 +191,20 @@ Create an app variable tm_outliers( label = "Wide and long datasets", outlier_var = list( - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("AGE", "BMRKR1")), + choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = "AGE", fixed = FALSE ) ), - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADLB", select = select_spec( label = "Select variable:", - choices = variable_choices(ADLB, c("AVAL", "CHG2")), + choices = variable_choices(data[["ADLB"]], c("AVAL", "CHG2")), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -217,11 +212,14 @@ Create an app variable ) ), categorical_var = - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, subset = names(Filter(isTRUE, sapply(ADSL, is.factor)))), + choices = variable_choices( + data[["ADSL"]], + subset = names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor))) + ), selected = "RACE", multiple = FALSE, fixed = FALSE @@ -231,20 +229,20 @@ Create an app variable tm_outliers( label = "Multiple long datasets", outlier_var = list( - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( label = "Select variable:", - choices = variable_choices(ADRS, c("ADY", "EOSDY")), + choices = variable_choices(data[["ADRS"]], c("ADY", "EOSDY")), selected = "ADY", fixed = FALSE ) ), - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADLB", select = select_spec( label = "Select variable:", - choices = variable_choices(ADLB, c("AVAL", "CHG2")), + choices = variable_choices(data[["ADLB"]], c("AVAL", "CHG2")), selected = "AVAL", multiple = FALSE, fixed = FALSE @@ -252,21 +250,24 @@ Create an app variable ) ), categorical_var = list( - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADRS", select = select_spec( label = "Select variables:", - choices = variable_choices(ADRS, c("ARM", "ACTARM")), + choices = variable_choices(data[["ADRS"]], c("ARM", "ACTARM")), selected = "ARM", multiple = FALSE, fixed = FALSE ) ), - teal.transform::data_extract_spec( + teal.transform::data_extract_spec( dataname = "ADLB", select = select_spec( label = "Select variables:", - choices = variable_choices(ADLB, subset = names(Filter(isTRUE, sapply(ADLB, is.factor)))), + choices = variable_choices( + data[["ADLB"]], + subset = names(Filter(isTRUE, sapply(data[["ADLB"]], is.factor))) + ), selected = "RACE", multiple = FALSE, fixed = FALSE @@ -286,7 +287,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +
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", tm_a_regression( label = "Single wide dataset", - response = teal.transform::data_extract_spec( + response = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2")), + choices = variable_choices(data[["ADSL"]], c("BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), - regressor = teal.transform::data_extract_spec( + regressor = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("AGE", "SEX", "RACE")), + choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "RACE")), selected = "AGE", multiple = TRUE, fixed = FALSE @@ -224,21 +205,21 @@ Create an app variable tm_a_regression( label = "Two wide datasets", default_plot_type = 2, - response = teal.transform::data_extract_spec( + response = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2")), + choices = variable_choices(data[["ADSL"]], c("BMRKR1", "BMRKR2")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), - regressor = teal.transform::data_extract_spec( + regressor = teal.transform::data_extract_spec( dataname = "ADSL2", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL2, c("AGE", "SEX", "RACE")), + choices = variable_choices(data[["ADSL2"]], c("AGE", "SEX", "RACE")), selected = c("AGE", "RACE"), multiple = TRUE, fixed = FALSE @@ -248,35 +229,35 @@ Create an app variable tm_a_regression( label = "Same long datasets (same subset)", default_plot_type = 2, - response = teal.transform::data_extract_spec( + response = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE, c("AVAL", "CNSR")), + choices = variable_choices(data[["ADTTE"]], c("AVAL", "CNSR")), selected = "AVAL", multiple = FALSE, fixed = FALSE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select parameter:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = "PFS", multiple = FALSE ) ), - regressor = teal.transform::data_extract_spec( + regressor = teal.transform::data_extract_spec( dataname = "ADTTE", select = select_spec( label = "Select variable:", - choices = variable_choices(ADTTE, c("AGE", "CNSR", "SEX")), + choices = variable_choices(data[["ADTTE"]], c("AGE", "CNSR", "SEX")), selected = c("AGE", "CNSR", "SEX"), multiple = TRUE ), - filter = teal.transform::filter_spec( + filter = teal.transform::filter_spec( label = "Select parameter:", vars = "PARAMCD", - choices = value_choices(ADTTE, "PARAMCD", "PARAM"), + choices = value_choices(data[["ADTTE"]], "PARAMCD", "PARAM"), selected = "PFS", multiple = FALSE ) @@ -284,20 +265,20 @@ Create an app variable ), tm_a_regression( label = "Wide and long datasets", - response = teal.transform::data_extract_spec( + response = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[2], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[2], multiple = TRUE, label = "Select measurement:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[2], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[2], multiple = TRUE, label = "Select visit:" ) @@ -310,11 +291,11 @@ Create an app variable fixed = TRUE ) ), - regressor = teal.transform::data_extract_spec( + regressor = teal.transform::data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", - choices = variable_choices(ADSL, c("BMRKR1", "BMRKR2", "AGE")), + choices = variable_choices(data[["ADSL"]], c("BMRKR1", "BMRKR2", "AGE")), selected = "AGE", multiple = TRUE, fixed = FALSE @@ -324,20 +305,20 @@ Create an app variable tm_a_regression( label = "Same long datasets (different subsets)", default_plot_type = 2, - response = teal.transform::data_extract_spec( + response = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = TRUE, label = "Select lab:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["ADLB"]]$AVISIT)[1], multiple = TRUE, label = "Select visit:" ) @@ -349,26 +330,26 @@ Create an app variable fixed = TRUE ) ), - regressor = teal.transform::data_extract_spec( + regressor = teal.transform::data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", - choices = value_choices(ADLB, "PARAMCD", "PARAM"), - selected = levels(ADLB$PARAMCD)[1], + choices = value_choices(data[["ADLB"]], "PARAMCD", "PARAM"), + selected = levels(data[["ADLB"]]$PARAMCD)[1], multiple = FALSE, label = "Select labs:" ), filter_spec( vars = "AVISIT", - choices = levels(ADLB$AVISIT), - selected = levels(ADLB$AVISIT)[1], + choices = levels(data[["ADLB"]]$AVISIT), + selected = levels(data[["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[["ADLB"]], c("AVAL", "AGE", "BMRKR1", "BMRKR2", "SEX", "ARM")), selected = c("AVAL", "BMRKR1"), multiple = TRUE ) @@ -386,7 +367,7 @@ Run the app shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024)) - +