lyt <-basic_table(title ="Extent of Exposure by Ethnic Origin: Safety-Evaluable Patients",main_footer ="* Patient Time is the sum of exposure across all patients in days.",show_colcounts =TRUE) %>%analyze_patients_exposure_in_cols(var ="ETHNIC",col_split =TRUE,add_total_level =TRUE,custom_label ="Total" ) %>%append_topleft(c("", "Ethnicity"))result <-build_table(lyt, df = anl, alt_counts_df = adsl_f)result
Extent of Exposure by Ethnic Origin: Safety-Evaluable Patients
——————————————————————————————————————————————————
Patients Person time
Ethnicity (N=400) (N=400)
——————————————————————————————————————————————————
HISPANIC OR LATINO 28 (7.0%) 2423
NOT HISPANIC OR LATINO 165 (41.2%) 15570
NOT REPORTED 18 (4.5%) 2085
UNKNOWN 6 (1.5%) 563
Total 217 (54.2%) 20641
——————————————————————————————————————————————————
* 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" )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.