library(dplyr)
library(teal.modules.general)
library(teal.modules.clinical)
# Prepare data object
data <- teal_data()
data <- within(data, {
ADSL <- rADSL
})
join_keys(data) <- default_cdisc_join_keys["ADSL"]
# Prepare module inputs
ADSL <- data[["ADSL"]]
cs_arm_var <- choices_selected(
choices = variable_choices(ADSL, subset = c("ARMCD", "ARM")),
selected = "ARM"
)
demog_vars_adsl <- ADSL |>
select(where(is.numeric) | where(is.factor)) |>
names()
# Create app
app <- init(
data = data,
modules = list(
tm_data_table("Data Table"),
tm_t_summary(
label = "Demographic Table",
dataname = "ADSL",
arm_var = cs_arm_var,
summarize_vars = choices_selected(
choices = variable_choices(ADSL, demog_vars_adsl),
selected = c("SEX", "AGE", "RACE")
)
)
)
)
if (Sys.getenv("QUARTO_ROOT") == "") {
shinyApp(app$ui, app$server)
}
Exercise 2
Enhance your application with pre-built modules!
Reference:
teal.modules.general::tm_data_table()
to create a data previewer moduleteal.modules.clinical::tm_t_summary()
to create a demographic summary table:- please read the documentation - especially
arm_var
andsummarize_vars
argument and what data type it takes - use both
"ARM"
and"ARMCD"
asarm_var
- use
"SEX"
,"AGE"
and"RACE"
assummarize_vars
- please read the documentation - especially
Example
App
Exercise
The module output requires further tweaks:
We dont’ want to have “ALL PATIENT” column - let’s remove it. Please read function documentation and identify the argument to be changed.
It is possible to select “ARM” in the “Summarize Variables” input which does not make much sense. Let’s limit the selection to only a few interesting columns of your choice. Which object to change?
Let’s create two modules in the same application - one with “ARM” column as
arm_var
and the other with “ARMCD”.