tbl_strata_nested_stack {gtsummary} | R Documentation |
Stratified Nested Stacking
Description
This function stratifies your data frame, builds gtsummary tables, and
stacks the resulting tables in a nested style. The underlying functionality
is similar to tbl_strata()
, except the resulting tables are nested or indented
within each group.
NOTE: The header from the first table is used for the final table. Oftentimes, this header will include incorrect Ns and must be updated.
Usage
tbl_strata_nested_stack(
data,
strata,
.tbl_fun,
...,
row_header = "{strata}",
quiet = FALSE
)
Arguments
data |
( |
strata |
( |
.tbl_fun |
( |
... |
Additional arguments passed on to the |
row_header |
( |
quiet |
(scalar |
Value
a stacked 'gtsummary' table
Examples
# Example 1 ----------------------------------
tbl_strata_nested_stack(
trial,
strata = trt,
.tbl_fun = ~ .x |>
tbl_summary(include = c(age, grade), missing = "no") |>
modify_header(all_stat_cols() ~ "**Summary Statistics**")
)
# Example 2 ----------------------------------
tbl_strata_nested_stack(
trial,
strata = trt,
.tbl_fun = ~ .x |>
tbl_summary(include = c(age, grade), missing = "no") |>
modify_header(all_stat_cols() ~ "**Summary Statistics**"),
row_header = "{strata}, n={n}"
) |>
# bold the row headers; print `x$table_body` to see hidden columns
modify_bold(columns = "label", rows = tbl_indent_id1 > 0)