# When summary table contains only categorical or only numeric parameterssplit_fun <- drop_split_levelslyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%split_rows_by("PARCAT2", split_label ="\nParameter Category (Drug A/Drug B)", label_pos ="topleft") %>%split_rows_by("PARAM", split_fun = split_fun) %>%analyze_vars(vars ="AVAL")result <-build_table(lyt = lyt, df = adex, alt_counts_df = adsl)result
A: Drug X B: Placebo C: Combination
Parameter Category (Drug A/Drug B) (N=134) (N=134) (N=132)
—————————————————————————————————————————————————————————————————————————————————————————————————
Drug A
Overall duration (days)
n 75 67 75
Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5)
Median 77.0 80.0 78.0
Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0
Total dose administered
n 75 67 75
Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)
Median 6720.0 6480.0 7200.0
Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0
Total number of doses administered
n 75 67 75
Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0)
Median 7.0 7.0 7.0
Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0
Total number of missed doses during study
n 75 67 75
Mean (SD) 10.5 (5.9) 10.0 (6.1) 9.5 (5.5)
Median 10.0 11.0 9.0
Min - Max 0.0 - 20.0 0.0 - 19.0 0.0 - 20.0
Drug B
Overall duration (days)
n 59 67 57
Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2)
Median 79.0 76.0 65.0
Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0
Total dose administered
n 59 67 57
Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)
Median 6720.0 6240.0 6480.0
Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0
Total number of doses administered
n 59 67 57
Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0)
Median 7.0 7.0 7.0
Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0
Total number of missed doses during study
n 59 67 57
Mean (SD) 9.1 (6.5) 10.0 (6.3) 10.7 (5.8)
Median 9.0 10.0 11.0
Min - Max 0.0 - 20.0 0.0 - 20.0 1.0 - 20.0
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.
A: Drug X B: Placebo C: Combination
Parameter Category (Drug A/Drug B) (N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————
Drug A
Overall duration (days)
n 75 67 75
Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5)
Median 77.0 80.0 78.0
Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0
Overall duration (days)
n 75 67 75
0 - 30 12 (16%) 12 (17.9%) 15 (20%)
31 - 60 18 (24%) 12 (17.9%) 14 (18.7%)
61 - 90 19 (25.3%) 15 (22.4%) 18 (24%)
>= 91 26 (34.7%) 28 (41.8%) 28 (37.3%)
Total dose administered
n 75 67 75
Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)
Median 6720.0 6480.0 7200.0
Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0
Total number of doses administered
n 75 67 75
Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0)
Median 7.0 7.0 7.0
Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0
Drug B
Overall duration (days)
n 59 67 57
Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2)
Median 79.0 76.0 65.0
Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0
Overall duration (days)
n 59 67 57
0 - 30 8 (13.6%) 10 (14.9%) 16 (28.1%)
31 - 60 14 (23.7%) 16 (23.9%) 12 (21.1%)
61 - 90 15 (25.4%) 17 (25.4%) 11 (19.3%)
>= 91 22 (37.3%) 24 (35.8%) 18 (31.6%)
Total dose administered
n 59 67 57
Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)
Median 6720.0 6240.0 6480.0
Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0
Total number of doses administered
n 59 67 57
Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0)
Median 7.0 7.0 7.0
Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0
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.
A: Drug X B: Placebo C: Combination
Parameter Category (Drug A/Drug B) (N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————
Drug A
Overall duration (days)
n 75 67 75
Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5)
Median 77.0 80.0 78.0
Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0
Overall duration (days)
n 75 67 75
0 - 30 12 (16%) 12 (17.9%) 15 (20%)
31 - 60 18 (24%) 12 (17.9%) 14 (18.7%)
61 - 90 19 (25.3%) 15 (22.4%) 18 (24%)
>= 91 26 (34.7%) 28 (41.8%) 28 (37.3%)
Total dose administered
n 75 67 75
Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)
Median 6720.0 6480.0 7200.0
Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0
Total number of doses administered
n 75 67 75
Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0)
Median 7.0 7.0 7.0
Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0
Missed Doses
n 75 67 75
At least 1 missed dose 74 (55.2%) 63 (47%) 73 (55.3%)
At least 5 missed doses 59 (44%) 49 (36.6%) 59 (44.7%)
At least 10 missed doses 41 (30.6%) 38 (28.4%) 37 (28%)
At least 15 missed doses 26 (19.4%) 21 (15.7%) 16 (12.1%)
Drug B
Overall duration (days)
n 59 67 57
Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2)
Median 79.0 76.0 65.0
Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0
Overall duration (days)
n 59 67 57
0 - 30 8 (13.6%) 10 (14.9%) 16 (28.1%)
31 - 60 14 (23.7%) 16 (23.9%) 12 (21.1%)
61 - 90 15 (25.4%) 17 (25.4%) 11 (19.3%)
>= 91 22 (37.3%) 24 (35.8%) 18 (31.6%)
Total dose administered
n 59 67 57
Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)
Median 6720.0 6240.0 6480.0
Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0
Total number of doses administered
n 59 67 57
Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0)
Median 7.0 7.0 7.0
Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0
Missed Doses
n 59 67 57
At least 1 missed dose 56 (41.8%) 63 (47%) 57 (43.2%)
At least 5 missed doses 41 (30.6%) 50 (37.3%) 47 (35.6%)
At least 10 missed doses 27 (20.1%) 36 (26.9%) 31 (23.5%)
At least 15 missed doses 17 (12.7%) 18 (13.4%) 20 (15.2%)
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)library(tidyr)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)adex <- adex %>%filter(PARCAT1 =="OVERALL") %>%select(STUDYID, USUBJID, ACTARM, PARAMCD, PARAM, AVAL, PARCAT2) %>%mutate(PARAMCD =as.character(PARAMCD),AVALC ="" ) %>%droplevels()# Add new param tdurd for treatment duration.set.seed(99)tdurd_adsl <- adsl %>%select(STUDYID, USUBJID, ACTARM) %>%mutate(PARAMCD ="TDURD",PARAM ="Overall duration (days)",AVAL =sample(1:150, size =nrow(adsl), replace =TRUE),AVALC =case_when(0<= AVAL & AVAL <=30~"0 - 30",31<= AVAL & AVAL <=60~"31 - 60",61<= AVAL & AVAL <=90~"61 - 90",TRUE~">= 91" ) )tdurd <- adex %>%filter(PARAMCD =="TNDOSE") %>%select(STUDYID, USUBJID, PARCAT2) %>%left_join(tdurd_adsl, by =c("STUDYID", "USUBJID"))# Add new param tndosmis for missed doses.tndosmis_adsl <- adsl %>%select(STUDYID, USUBJID, ACTARM) %>%mutate(PARAMCD ="TNDOSMIS",PARAM ="Total number of missed doses during study",AVAL =sample(0:20, size =nrow(adsl), replace =TRUE),AVALC ="" )tndosmis <- adex %>%filter(PARAMCD =="TNDOSE") %>%select(STUDYID, USUBJID, PARCAT2) %>%left_join(tndosmis_adsl, by =c("STUDYID", "USUBJID"))adex <- dplyr::bind_rows(adex, tdurd, tndosmis) %>%mutate(PARAM =factor( PARAM,levels =c("Overall duration (days)", "Total dose administered", "Total number of doses administered","Total number of missed doses during study" ) ))
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.