please read the documentation - especially arm_var and summarize_vars argument and what data type it takes
use both "ARM" and "ARMCD" as arm_var
use "SEX", "AGE" and "RACE" as summarize_vars
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 datanamesdatanames <-c("ADSL")datanames(data) <- datanames
Warning: `datanames<-()` was deprecated in teal.data 0.7.0.
ℹ invalid to use `datanames()<-` or `names()<-` on an object of class
`teal_data`. See ?names.teal_data
# set join_keysjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADSL <- 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)
Warning: `build_app_title()` was deprecated in teal 0.16.0.
ℹ Use `modify_title()` on the object created using the `init`.
Warning: The `title` argument of `init()` is deprecated as of teal 0.16.0.
ℹ Use `modify_title()` on the teal app object instead. See ?modify_title for
examples and more details.
Warning: The `header` argument of `init()` is deprecated as of teal 0.16.0.
ℹ Use `modify_header()` on the teal app object instead. See ?modify_header for
examples and more details.
Warning: The `footer` argument of `init()` is deprecated as of teal 0.16.0.
ℹ Use `modify_footer()` on the teal app object instead. See ?modify_footer for
examples and more details.
if (Sys.getenv("QUARTO_ROOT") =="") {shinyApp(app$ui, app$server)}