0
library(tidyverse)
library(reprex)
y <-c('A','B','C','A')
x <-c('male','male','female',NA)
df <- as.data.frame(cbind(x,y))
reprex()
tbl_summary(df)

Output

I want to add 100% next to N=4. How can I do that?

HSC
  • 129
  • 6

1 Answers1

3

If your headings are always going to sum to 100%, then you could try modifying the header to add '(100%)' manually:

tbl_summary(df) %>% 
  modify_header(update = "stat_0" ~ "N = {n} (100%)")

For other scenarios, the modify_header() function in gtsummary should be able to do what you want.

semaphorism
  • 836
  • 3
  • 13