pharmaverse / pharmaverse/rtables
Bug: `summarize_row_groups()` does not provide the correct `.ref_group`
Open
@gmbecker is already working on this.
Since Sep 8, 2026.
- Dominant language
- R
- Stars
- 260
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.