Code
# Define the split function
split_fun <- drop_split_levels
lyt <- basic_table() %>%
split_cols_by("postbaseline_label") %>%
split_cols_by("AVALC") %>%
split_rows_by("ARM", split_fun = split_fun, label_pos = "topleft", split_label = obj_label(adeg_f$ARM)) %>%
add_rowcounts() %>%
analyze_vars(
"BASEC",
denom = "N_row",
.stats = "count_fraction",
na.rm = FALSE
) %>%
append_varlabels(adeg_f, c("BASEC"), indent = 1L)
result <- build_table(lyt, adeg_f)
result
Description of Planned Arm Post-Baseline
Baseline Normal Abnormal Missing
———————————————————————————————————————————————————————————————
A: Drug X (N=134)
Normal 20 (14.9%) 81 (60.4%) 1 (0.7%)
Abnormal 11 (8.2%) 19 (14.2%) 0
Missing 0 1 (0.7%) 1 (0.7%)
B: Placebo (N=134)
Normal 18 (13.4%) 81 (60.4%) 2 (1.5%)
Abnormal 3 (2.2%) 28 (20.9%) 0
Missing 0 2 (1.5%) 0
C: Combination (N=132)
Normal 26 (19.7%) 69 (52.3%) 1 (0.8%)
Abnormal 6 (4.5%) 29 (22%) 0
Missing 1 (0.8%) 0 0