# NOT RUN {
# Example 1 (general) -------------------------------------------------------
as_kable_extra_ex1_gen <-
trial %>%
select(trt, age, stage) %>%
tbl_summary(by = trt) %>%
bold_labels() %>%
as_kable_extra()
# Example 2 (PDF via LaTeX) -------------------------------------------------
custom_names <- c(
"\\textbf{Characteristic}",
"\\textbf{Drug A}\n\\textit{N = 98}",
"\\textbf{Drug B}\n\\textit{N = 102}"
)
as_kable_extra_ex2_pdf <-
trial %>%
select(trt, age, stage) %>%
tbl_summary(
by = trt,
statistic = list(all_categorical() ~ "{n} ({p}\\%)")
) %>%
bold_labels() %>%
modify_footnote(
update = all_stat_cols() ~ "Median (IQR); n (%)"
) %>%
as_kable_extra(
format = "latex",
col.names = kableExtra::linebreak(custom_names, align = "c"),
escape = FALSE
)
# Example 3 (PDF via LaTeX) -------------------------------------------------
as_kable_extra_ex3_pdf <-
trial %>%
select(trt, age, stage) %>%
tbl_summary(by = trt) %>%
bold_labels() %>%
as_kable_extra(
format = "latex",
booktabs = TRUE,
longtable = TRUE,
linesep = ""
) %>%
kableExtra::kable_styling(
position = "left",
latex_options = c("striped", "repeat_header"),
stripe_color = "gray!15"
)
# }
Run the code above in your browser using DataLab