Reputation: 85
I am trying to use the tbl_stack function from the gtsummary package, but the output text from using the group_header argument looks too visually similar to the rest of the labels. Ideally I would like to format the text with either bold, underline, or change the size to make it clear that I am displaying a separate section. Is there any way to accomplish group_header text formatting in the gtsummary package?
In the below example (taken from this issue: https://github.com/ddsjoberg/gtsummary/issues/669), I would ideally like the words "Demographics" and "Lab Values" to be in bold.
library(gtsummary)
tt <-
trial %>%
select(trt, response, age) %>%
tbl_summary(by = trt, missing = "no")
# stacking two tbl_summary objects with header between
tbl_stack(list(tt, tt), group_header = c("Demographics", "Lab Values"))
Upvotes: 7
Views: 3061
Reputation: 11784
Those kind of style changes are available within the {gt} package. Convert the {gtsummary} table to {gt} using as_gt()
, then make use of the {gt} styling functions. Example bolding below!
library(gtsummary)
tt <-
trial %>%
select(trt, response, age) %>%
tbl_summary(by = trt, missing = "no")
# stacking two tbl_summary objects with header between
tbl_stack(list(tt, tt), group_header = c("Demographics", "Lab Values")) %>%
as_gt() %>%
gt::tab_style(
style = gt::cell_text(weight = "bold"),
locations = gt::cells_row_groups(groups = everything())
)
Upvotes: 9