| modify | R Documentation |
These functions assist with modifying the aesthetics/style of a table.
modify_header() update column headers
modify_spanning_header() update/add spanning headers
The functions often require users to know the underlying column names.
Run show_header_names() to print the column names to the console.
modify_header(x, ..., text_interpret = c("md", "html"), quiet, update)
modify_spanning_header(
x,
...,
text_interpret = c("md", "html"),
level = 1L,
quiet,
update
)
remove_spanning_header(x, columns = everything(), level = 1L)
show_header_names(x, show_hidden = FALSE, include_example, quiet)
x |
( |
... |
Use Use the |
text_interpret |
( |
update, quiet |
|
level |
( |
columns |
( |
|
(scalar | |
include_example |
Updated gtsummary object
tbl_summary(), tbl_svysummary(), and tbl_cross()When assigning column headers and spanning headers,
you may use {N} to insert the number of observations.
tbl_svysummary objects additionally have {N_unweighted} available.
When there is a stratifying by= argument present, the following fields are
additionally available to stratifying columns: {level}, {n}, and {p}
({n_unweighted} and {p_unweighted} for tbl_svysummary objects)
Syntax follows glue::glue(), e.g. all_stat_cols() ~ "**{level}**, N = {n}".
When assigning column headers for tbl_regression tables,
you may use {N} to insert the number of observations, and {N_event}
for the number of events (when applicable).
Daniel D. Sjoberg
# create summary table
tbl <- trial |>
tbl_summary(by = trt, missing = "no", include = c("age", "grade", "trt")) |>
add_p()
# print the column names that can be modified
show_header_names(tbl)
# Example 1 ----------------------------------
# updating column headers
tbl |>
modify_header(label = "**Variable**", p.value = "**P**")
# Example 2 ----------------------------------
# updating headers add spanning header
tbl |>
modify_header(all_stat_cols() ~ "**{level}**, N = {n} ({style_percent(p)}%)") |>
modify_spanning_header(all_stat_cols() ~ "**Treatment Received**")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.