Reputation: 51
Hopefully, a simple answer that someone knows off the top of their head!
I am using tbl_summary
and trying to modify my header to have n(%) instead of the standard format of N = 57. I would normally use modify_header(stat_by)
but can't when by
isn't included.
Example:
trial %>%
select(trt, marker, stage) %>%
tbl_summary() %>%
modify_header(stat_by = "**{level}**, n(%)")
Any ideas most appreciated!
Upvotes: 1
Views: 2522
Reputation: 578
To edit the text of your header, you can use the update
argument in modify_header()
. stat_0
refers to the statistic column, so this is the one you need to change:
library(gtsummary)
trial %>%
select(trt, marker, stage) %>%
tbl_summary() %>%
modify_header(update = stat_0 ~ "**n(%)**")
You can use {glue} syntax if you want to insert a statistic as well:
trial %>%
select(trt, marker, stage) %>%
tbl_summary() %>%
modify_header(update = stat_0 ~ "**n(%), N = {N}**")
Good luck!
Upvotes: 2