pharmaverse / pharmaverse/rtables
Spacing in header is wrong when wrapping occurs if there are nonnested facets
Open
@gmbecker is already working on this.
Since Oct 29, 2025.
bug
- Dominant language
- R
- Stars
- 260
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
The logic which handled spacing other elements of a header when a label needs word wrapping ends up assuming the column space is a single nested structure. We can see the consequence of that like so:
adsl <- ex_adsl
adsl$long_strata_lbls <- paste("really long strata label ", adsl$STRATA1)
lyt <- basic_table() |>
split_cols_by("ARM") |>
split_cols_by("SEX", split_fun = keep_split_levels(c("F", "M")), show_colcounts = TRUE) |>
split_cols_by("STRATA1", nested = FALSE, labels_var = "long_strata_lbls") |>
analyze("AGE")
tbl <- build_table(lyt, adsl)
cwds <- propose_column_widths(tbl)
cwds[8:10] <- 12
When we export the table with those column widths we get:
> cat(export_as_txt(tbl, colwidths = cwds))
A: Drug X B: Placebo C: Combination
F M F M F M
really really really
long strata long strata long strata
(N=79) (N=51) (N=77) (N=55) (N=66) (N=60) label A label B label C
—————————————————————————————————————————————————————————————————————————————————————————————————————————
Mean 32.76 35.57 34.12 37.44 35.20 35.38 34.19 35.36 35.01
Which is obviously not correct. This will be a tricky one to fix but it should be doable.
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.