Here's an example how to merge the CI into the table. Happy Programming!
library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.5.0'
svy <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq)
# put the CI in a tibble with the variable name
tbl_ci <-
survey::svyciprop(~I(Sex == "Female"), svy) %>%
attr("ci") %>%
style_sigfig(scale = 100) %>%
paste0("%", collapse = ", ") %>%
{tibble::tibble(variable = "Sex", ci = .)}
tbl <-
svy %>%
tbl_svysummary(
include = Sex,
value = Sex ~ "Female"
) %>%
# merge in the CI to the gtsummary table
modify_table_body(
~.x %>%
dplyr::left_join(
tbl_ci,
by = "variable"
)
) %>%
modify_header(ci = "**95% CI**")
Created on 2021-11-23 by the reprex package (v2.0.1)