Enhance your application with pre-built modules!
Code
library(dplyr)
library(random.cdisc.data)
library(nestcolor)
library(teal.modules.general)
library(teal.modules.clinical)
## Data reproducible code ----
data <- teal_data()
data <- within(data, {
ADSL <- radsl(cached = TRUE)
adsl_labels <- col_labels(ADSL, fill = FALSE)
char_vars_asl <- names(Filter(isTRUE, sapply(ADSL, is.character)))
})
# set datanames
datanames <- c("ADSL")
datanames(data) <- datanames
# set join_keys
join_keys(data) <- default_cdisc_join_keys[datanames]
## Reusable Configuration For Modules
ADSL <- data[["ADSL"]]
arm_vars <- c("ARMCD", "ARM")
cs_arm_var <- choices_selected(
choices = variable_choices(ADSL, subset = arm_vars),
selected = "ARM"
)
date_vars_asl <- names(ADSL)[vapply(ADSL, function(x) inherits(x, c("Date", "POSIXct", "POSIXlt")), logical(1))]
demog_vars_asl <- names(ADSL)[!(names(ADSL) %in% c("USUBJID", "STUDYID", date_vars_asl))]
header <- tags$span(
style = "display: flex; align-items: center; justify-content: space-between; margin: 10px 0 10px 0;",
tags$span("Exercise 1", style = "font-size: 30px;"),
)
footer <- tags$p(
"This teal app is brought to you by PhUSE SDE Basel",
)
app <- init(
data = data,
modules = modules(
tm_front_page(
label = "App Info",
header_text = c(
"Info about input data source" =
"This app uses CDISC ADaM datasets randomly generated by `random.cdisc.data` R packages"
),
tables = list(`NEST packages used in this demo app` = data.frame(
Packages = c("teal.modules.general", "teal.modules.clinical", "random.cdisc.data")
))
),
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_asl),
selected = c("SEX", "AGE", "RACE")
)
)
),
title = build_app_title("Basic Teal Demo App"),
header = header,
footer = footer
)
[INFO] 2025-01-07 10:35:33.2877 pid:7400 token:[] teal.modules.general Initializing tm_front_page
[INFO] 2025-01-07 10:35:33.2906 pid:7400 token:[] teal.modules.general Initializing tm_data_table
if (Sys.getenv("QUARTO_ROOT") == "") {
shinyApp(app$ui, app$server)
}