Reputation: 45
Is there a way to add the sample size in the tbl_regression output. Meaning the actual sample used for the model?
#example
tbl_regression(model, exponentiate = TRUE)
Thanks,
#gtsummary
Upvotes: 2
Views: 789
Reputation: 11680
There are two ways to add the model N to a tbl_regression()
table.
modify_header()
to include the N in a column header. Requires gtsummary v1.3.6 or higher.add_n()
to add a column to the table with the number of observations. Requires the current dev version of gtsummary. Install the dev version with remotes::install_github("ddsjoberg/gtsummary")
library(gtsummary)
packageVersion("gtsummary")
#> '1.3.6.9013'
glm(response ~ age, trial, family = binomial) %>%
tbl_regression(exponentiate = TRUE) %>%
modify_header(label ~ "**Characteristic, N = {N}**") %>% # Add N to the column header
add_n() %>% # Add N column to table
add_nevent() # Add Event N column to table
Upvotes: 1