split_fun <- drop_split_levelslyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%add_overall_col("All Patients") %>%analyze_num_patients(vars ="USUBJID",count_by ="CMSEQ",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one treatment",nonunique ="Total number of treatments" ),show_labels ="hidden" ) %>%count_occurrences(vars ="CMDECOD") %>%append_topleft(paste("\nOther Treatment"))result <-build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%sort_at_path(path =c("CMDECOD"),scorefun = score_occurrences )result
A: Drug X B: Placebo C: Combination All Patients
Other Treatment (N=134) (N=134) (N=132) (N=400)
————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%)
Total number of treatments 415 414 460 1289
medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%)
medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%)
medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%)
medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%)
medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%)
medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%)
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(dplyr)library(tern)adsl <- random.cdisc.data::cadsladcm <- random.cdisc.data::cadcmadcm$CMSEQ <-as.factor(adcm$CMSEQ)# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.# If you want your missing levels to show as "No Coding Available", please useadsl <-df_explicit_na(adsl, na_level ="No Coding Available")adcm <-df_explicit_na(adcm, na_level ="No Coding Available")# Keep only safety-evaluable patients and concomitant medicationsadsl <- adsl %>%filter(SAFFL =="Y")# Keep only concomitant medicationsadcm <- adcm %>%filter(ATIREL =="CONCOMITANT")
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.