# \donttest{
# create summary table
tbl <- trial[c("age", "grade", "trt")] %>%
tbl_summary(by = trt, missing = "no") %>%
add_p()
# print the column names that can be modified
show_header_names(tbl)
# Example 1 ----------------------------------
# updating column headers, footnote, and table caption
modify_ex1 <- tbl %>%
modify_header(label = "**Variable**", p.value = "**P**") %>%
modify_footnote(all_stat_cols() ~ "median (IQR) for Age; n (%) for Grade") %>%
modify_caption("**Patient Characteristics** (N = {N})")
# Example 2 ----------------------------------
# updating headers, remove all footnotes, add spanning header
modify_ex2 <- tbl %>%
modify_header(all_stat_cols() ~ "**{level}**, N = {n} ({style_percent(p)}%)") %>%
# use `modify_footnote(everything() ~ NA, abbreviation = TRUE)` to delete abbrev. footnotes
modify_footnote(update = everything() ~ NA) %>%
modify_spanning_header(all_stat_cols() ~ "**Treatment Received**")
# Example 3 ----------------------------------
# updating an abbreviation in table footnote
modify_ex3 <-
glm(response ~ age + grade, trial, family = binomial) %>%
tbl_regression(exponentiate = TRUE) %>%
modify_footnote(ci = "CI = Credible Interval", abbreviation = TRUE)
# }
Run the code above in your browser using DataLab