Hi @drchinn!
There is no straight-forward way to do this. I did write something for you, however. I hope it helps.
library(gtsummary)
library(tidyverse)
tbl <-
trial %>%
select(grade, response) %>%
tbl_summary(missing = "no") %>%
add_n() %>%
modify_footnote(everything() ~ NA)
# calculate CI and put it in format that can merge with tbl$table_body
tbl_ci <-
tbl$meta_data %>%
filter(summary_type %in% c("categorical", "dichotomous")) %>%
select(summary_type, var_label, df_stats) %>%
unnest(df_stats) %>%
mutate(
conf.low = (p - qnorm(0.975) * sqrt(p * (1 - p) / N)) %>% style_percent(symbol = TRUE),
conf.high =( p + qnorm(0.975) * sqrt(p * (1 - p) / N)) %>% style_percent(symbol = TRUE),
ci = str_glue("{conf.low}, {conf.high}"),
label = coalesce(variable_levels, var_label),
row_type = ifelse(summary_type == "dichotomous", "label", "level")
) %>%
select(variable, row_type, label, ci)
# merge in CI and set column header
tbl %>%
modify_table_body(
left_join,
tbl_ci,
by = c("variable", "row_type", "label")
) %>%
modify_table_header(
ci,
hide = FALSE,
label = "**95% CI**"
)