-
Notifications
You must be signed in to change notification settings - Fork 220
tab_stubhead() errors in RTF when there are fewer labels than columns #2118
Copy link
Copy link
Open
Labels
Description
Prework
- Read and agree to the code of conduct and contributing guidelines.
- If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
Description
Thanks for all the efforts to support flexible output types! We noticed the following issue for RTF specifically:
For tables with multi-column stub (multiple rowname_col's and/or row_grp_as_column = TRUE), we can use tab_stubhead() to define the labels. These can be one label for all columns, one label per column, or no labels. All works well in HTML but doing 1 label or no labels fails in RTF:
library(gt)
# Both stubs labeled - OK
tab1 <- exibble |>
gt(
rowname_col = c("group", "char")
)|>
tab_stubhead(
label = c("Group","Char")
)
tab1 |>
gt::gtsave("test.rtf")
# Both stubheads labeled w/ empty strings - OK
tab2 <- exibble |>
gt(
rowname_col = c("group", "char")
)|>
tab_stubhead(
label = c("","")
)
tab2 |>
gt::gtsave("test.rtf")
# One stubhead label - Error
tab3 <- exibble |>
gt(
rowname_col = c("group", "char")
) |>
tab_stubhead(
label = c("Group / Char")
)
tab3 |>
gt::gtsave("test.rtf")
#> Error in `x[[i]]`:
#> ! subscript out of bounds
# No stubhead labels - Error
tab4 <- exibble |>
gt(
rowname_col = c("group", "char")
)
tab4 |>
gt::gtsave("test.rtf")
#> Error in `x[[i]]`:
#> ! subscript out of boundsCreated on 2026-01-26 with reprex v2.1.1
Reactions are currently unavailable