Skip to content

Spacing in header is wrong when wrapping occurs if there are nonnested facets #1042

@gmbecker

Description

@gmbecker

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions