# NOT RUN {
# basic gtsummary tbl to build upon
as_kable_extra_base <-
trial %>%
select(trt, age, stage) %>%
tbl_summary(by = trt) %>%
bold_labels()
# Example 1 (PDF via LaTeX) ---------------------
# add linebreak in table header with '\n'
as_kable_extra_ex1_pdf <-
as_kable_extra_base %>%
modify_header(all_stat_cols() ~ "**{level}**\n*N = {n}*") %>%
as_kable_extra()
# Example 2 (PDF via LaTeX) ---------------------
# additional styling in `knitr::kable()` and with
# call to `kableExtra::kable_styling()`
as_kable_extra_ex1_pdf <-
as_kable_extra_base %>%
as_kable_extra(
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