lyt <-basic_table(title ="Extent of Exposure by Age Group and Gender: Safety-Evaluable Patients",main_footer ="* Patient Time is the sum of exposure across all patients in days.") %>%split_cols_by("SEX", split_fun =add_overall_level("Total", first =FALSE)) %>%summarize_patients_exposure_in_cols(var ="AVAL", col_split =TRUE,.labels =c(n_patients ="Number of Patients", sum_exposure ="Patient Time*"),custom_label ="Total Number of Patients and Patient Time" ) %>%analyze_patients_exposure_in_cols(var ="AGEGR1",col_split =FALSE ) %>%append_topleft(c("", "Age group (years)"))result <-build_table(lyt, df = anl, alt_counts_df = adsl_f)result
Extent of Exposure by Age Group and Gender: Safety-Evaluable Patients
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Female Male Total
Age group (years) Number of Patients Patient Time* Number of Patients Patient Time* Number of Patients Patient Time*
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total Number of Patients and Patient Time 134 (58.0%) 12591 83 (49.1%) 8050 217 (54.2%) 20641
<65 134 (58.0%) 12591 82 (48.5%) 7970 216 (54.0%) 20561
>=65 0 (0.0%) 0 1 (0.6%) 80 1 (0.2%) 80
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
* Patient Time is the sum of exposure across all patients in days.
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
lyt <-basic_table(title ="Duration of Exposure: Safety-Evaluable Patients",main_footer ="* Patient Time is the sum of exposure across all patients in days.") %>%split_cols_by("SEX", split_fun =add_overall_level("Total", first =FALSE)) %>%summarize_patients_exposure_in_cols(var ="AVAL", col_split =TRUE,.labels =c(n_patients ="Number of Patients", sum_exposure ="Patient Time*"),custom_label ="Total Number of Patients and Patient Time" ) %>%analyze_patients_exposure_in_cols(var ="AGEGR2",col_split =FALSE ) %>%append_topleft(c("", "Age group (years)"))result <-build_table(lyt, df = anl, alt_counts_df = adsl_f) %>%prune_table()result
Duration of Exposure: Safety-Evaluable Patients
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Female Male Total
Age group (years) Number of Patients Patient Time* Number of Patients Patient Time* Number of Patients Patient Time*
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total Number of Patients and Patient Time 134 (58.0%) 12591 83 (49.1%) 8050 217 (54.2%) 20641
18 - 40 118 (51.1%) 11203 60 (35.5%) 5787 178 (44.5%) 16990
41 - 64 16 (6.9%) 1388 22 (13.0%) 2183 38 (9.5%) 3571
>=65 0 (0.0%) 0 1 (0.6%) 80 1 (0.2%) 80
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
* Patient Time is the sum of exposure across all patients in days.
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
library(tern)library(dplyr)adsl <- random.cdisc.data::cadsladex <- random.cdisc.data::cadex# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adex <-df_explicit_na(adex)# Simulate ADEX records with PARAMCD == "TDURD" as they are not in sample random.cdisc.data dataset.set.seed(1, kind ="Mersenne-Twister")adex2 <- adex %>%distinct(USUBJID, .keep_all =TRUE) %>%mutate(PARAMCD ="TDURD",PARAM ="Overall duration (days)",AVAL =sample(x =seq(1, 200), size =n(), replace =TRUE) ) %>%bind_rows(adex)# Now pre-processing steps are carried out.anl <- adex2 %>%filter( PARAMCD =="TDURD", PARCAT2 =="Drug A", SAFFL =="Y" ) %>%mutate(AGEGR1 =factor(ifelse(AGE <65, "<65", ">=65")),AGEGR2 =factor(case_when( AGE <18~"< 18", AGE >=18& AGE <=40~"18 - 40", AGE >40& AGE <=64~"41 - 64",TRUE~">=65" ), levels =c("< 18", "18 - 40", "41 - 64", ">=65")),SEX =factor(case_when( SEX =="F"~"Female", SEX =="M"~"Male" )) )adsl_f <- adsl %>%filter(adsl$SAFFL =="Y") %>%mutate(SEX =factor(case_when( SEX =="F"~"Female", SEX =="M"~"Male" )))
library(teal.modules.clinical)## Data reproducible codedata <-teal_data()data <-within(data, {library(dplyr) ADSL <- random.cdisc.data::cadsl ADEX <- random.cdisc.data::cadex labels <-col_labels(ADEX)set.seed(1, kind ="Mersenne-Twister") labels <-col_labels(ADEX) ADEX <- ADEX %>%distinct(USUBJID, .keep_all =TRUE) %>%mutate(PARAMCD ="TDURD",PARAM ="Overall duration (days)",AVAL =sample(x =seq(1, 200), size =n(), replace =TRUE),AVALU ="Days",SEX =factor(case_when( SEX =="F"~"Female", SEX =="M"~"Male" )) ) %>%bind_rows(ADEX)col_labels(ADEX) <- labels ADEX <- ADEX %>%mutate(AGEGR1 =factor(ifelse(AGE <65, "<65", ">=65")) %>%with_label("Age group (years)"),AGEGR2 =factor(case_when( AGE <18~"< 18", AGE >=18& AGE <=40~"18 - 40", AGE >40& AGE <=64~"41 - 64",TRUE~">=65" ), levels =c("< 18", "18 - 40", "41 - 64", ">=65")) %>%with_label("Age group (years)") ) ADSL <- ADSL %>%mutate(SEX =factor(case_when( SEX =="F"~"Female", SEX =="M"~"Male" )) %>%with_label("Sex"))})datanames <-c("ADSL", "ADEX")datanames(data) <- datanames
Warning: `datanames<-()` was deprecated in teal.data 0.6.1.
ℹ invalid to use `datanames()<-` or `names()<-` on an object of class
`teal_data`. See ?names.teal_data
shinylive allow you to modify to run shiny application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.