It seems that .ref_group is not correctly populated when using summarize_row_groups() with a custom tabulation function.
In the example below, analyze() correctly provides the reference group data, while summarize_row_groups() passes a zero-row .ref_group.
Example
nrow_refgrp <- function(df, labelstr = "", .ref_group) {
rcell(nrow(.ref_group), label = "nrow(.ref_group)")
}
lyt0 <- basic_table(show_colcounts = TRUE, top_level_section_div = " ") |>
split_cols_by("ARM", ref_group = "B: Placebo") |>
split_rows_by("SEX", split_fun = drop_split_levels, child_labels = "visible")
analyze()
lyt0 |>
analyze("AGE", afun = nrow_refgrp) |>
build_table(DM)
A: Drug X B: Placebo C: Combination
(N=121) (N=106) (N=129)
————————————————————————————————————————————————————————————
F
nrow(.ref_group) 56 56 56
M
nrow(.ref_group) 50 50 50
summarize_row_groups()
lyt0 |>
summarize_row_groups("SEX", format = NULL, cfun = nrow_refgrp) |>
build_table(DM)
A: Drug X B: Placebo C: Combination
(N=121) (N=106) (N=129)
————————————————————————————————————————————————————————————
F
nrow(.ref_group) 0 0 0
M
nrow(.ref_group) 0 0 0
It seems that
.ref_groupis not correctly populated when usingsummarize_row_groups()with a custom tabulation function.In the example below,
analyze()correctly provides the reference group data, whilesummarize_row_groups()passes a zero-row.ref_group.Example
analyze()summarize_row_groups()