Code
# Define the split function
split_fun <- drop_split_levels
lyt <- basic_table(show_colcounts = TRUE) %>%
split_cols_by("ARM") %>%
split_rows_by("AVISIT", split_fun = split_fun, label_pos = "topleft", split_label = obj_label(adlb_f_crp$AVISIT)) %>%
count_abnormal_by_baseline(
"ANRIND",
abnormal = c(Low = "LOW", High = "HIGH"),
.indent_mods = 4L
) %>%
append_varlabels(adlb_f_crp, "ANRIND", indent = 1L) %>%
append_topleft(" Baseline Status")
result <- build_table(
lyt = lyt,
df = adlb_f_crp,
alt_counts_df = adsl
) %>%
trim_rows()
result
Visit
Analysis Reference Range Indicator A: Drug X B: Placebo C: Combination
Baseline Status (N=134) (N=134) (N=132)
———————————————————————————————————————————————————————————————————————————————————————
WEEK 1 DAY 8
Low
Not low 16/119 (13.4%) 22/113 (19.5%) 24/112 (21.4%)
Low 2/15 (13.3%) 2/21 (9.5%) 7/20 (35%)
Total 18/134 (13.4%) 24/134 (17.9%) 31/132 (23.5%)
High
Not high 21/114 (18.4%) 20/112 (17.9%) 17/115 (14.8%)
High 2/20 (10%) 4/22 (18.2%) 3/17 (17.6%)
Total 23/134 (17.2%) 24/134 (17.9%) 20/132 (15.2%)
WEEK 2 DAY 15
Low
Not low 26/119 (21.8%) 20/113 (17.7%) 12/112 (10.7%)
Low 2/15 (13.3%) 3/21 (14.3%) 4/20 (20%)
Total 28/134 (20.9%) 23/134 (17.2%) 16/132 (12.1%)
High
Not high 15/114 (13.2%) 17/112 (15.2%) 15/115 (13%)
High 2/20 (10%) 4/22 (18.2%) 4/17 (23.5%)
Total 17/134 (12.7%) 21/134 (15.7%) 19/132 (14.4%)
WEEK 3 DAY 22
Low
Not low 15/119 (12.6%) 21/113 (18.6%) 18/112 (16.1%)
Low 0/15 3/21 (14.3%) 0/20
Total 15/134 (11.2%) 24/134 (17.9%) 18/132 (13.6%)
High
Not high 22/114 (19.3%) 18/112 (16.1%) 17/115 (14.8%)
High 2/20 (10%) 5/22 (22.7%) 1/17 (5.9%)
Total 24/134 (17.9%) 23/134 (17.2%) 18/132 (13.6%)
WEEK 4 DAY 29
Low
Not low 30/119 (25.2%) 13/113 (11.5%) 16/112 (14.3%)
Low 3/15 (20%) 2/21 (9.5%) 5/20 (25%)
Total 33/134 (24.6%) 15/134 (11.2%) 21/132 (15.9%)
High
Not high 17/114 (14.9%) 11/112 (9.8%) 16/115 (13.9%)
High 2/20 (10%) 6/22 (27.3%) 3/17 (17.6%)
Total 19/134 (14.2%) 17/134 (12.7%) 19/132 (14.4%)
WEEK 5 DAY 36
Low
Not low 17/119 (14.3%) 19/113 (16.8%) 16/112 (14.3%)
Low 2/15 (13.3%) 3/21 (14.3%) 5/20 (25%)
Total 19/134 (14.2%) 22/134 (16.4%) 21/132 (15.9%)
High
Not high 19/114 (16.7%) 17/112 (15.2%) 11/115 (9.6%)
High 4/20 (20%) 6/22 (27.3%) 2/17 (11.8%)
Total 23/134 (17.2%) 23/134 (17.2%) 13/132 (9.8%)