lyt <-basic_table(title ="Duration of Exposure: Safety-Evaluable Patients",main_footer ="* Patient Time is the sum of exposure across all patients in days.",show_colcounts =TRUE) %>%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 ="aval_months_cat",col_split =FALSE ) %>%append_topleft(c("", "Duration of exposure"))result <-build_table(lyt, df = anl, alt_counts_df = adsl_f)result
Duration of Exposure: Safety-Evaluable Patients
——————————————————————————————————————————————————————————————————————————————
Number of Patients Patient Time*
Duration of exposure (N=400) (N=400)
——————————————————————————————————————————————————————————————————————————————
Total Number of Patients and Patient Time 217 (54.2%) 20641
< 1 month 28 (7.0%) 504
1 to <3 months 79 (19.8%) 4727
3 to <6 months 101 (25.2%) 13690
>=6 months 9 (2.2%) 1720
——————————————————————————————————————————————————————————————————————————————
* 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(aval_months =day2month(AVAL),aval_months_cat =factor(case_when( aval_months <1~"< 1 month", aval_months >=1& aval_months <3~"1 to <3 months", aval_months >=3& aval_months <6~"3 to <6 months",TRUE~">=6 months" ), levels =c("< 1 month", "1 to <3 months", "3 to <6 months", ">=6 months")) )adsl_f <- adsl %>%filter(adsl$SAFFL =="Y")
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.