Description Usage Arguments Example Output See Also Examples
View source: R/modify_table_body.R
experimental
Function is for advanced manipulation of gtsummary tables.
It allow users to modify the .$table_body
data frame included
in each gtsummary object.
If a new column is added to the table, default printing instructions will then
be added to .$table_styling
. By default, columns are hidden.
To show a column, add a column header with modify_header()
.
1 | modify_table_body(x, fun, ...)
|
x |
gtsummary object |
fun |
A function or formula. If a function, it is used as is.
If a formula, e.g. |
... |
Additional arguments passed on to the mapped function |
Example 1
See gtsummary internals vignette
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Example 1 --------------------------------
# Add number of cases and controls to regression table
modify_table_body_ex1 <-
trial %>%
select(response, age, marker) %>%
tbl_uvregression(y = response,
method = glm,
method.args = list(family = binomial),
exponentiate = TRUE,
hide_n = TRUE) %>%
# adding number of non-events to table
modify_table_body(
~.x %>%
dplyr::mutate(N_nonevent = N_obs - N_event) %>%
dplyr::relocate(c(N_event, N_nonevent), .before = estimate)
) %>%
# assigning header labels
modify_header(N_nonevent = "**Control N**", N_event = "**Case N**") %>%
modify_fmt_fun(c(N_event, N_nonevent) ~ style_number)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.