Apply a formatting function after the primary formatting functions have been applied.
The function is similar to gt::text_transform().
modify_post_fmt_fun(x, fmt_fun, columns, rows = TRUE)(gtsummary)
A gtsummary object
(function)
a function that will be applied to the specified columns and rows.
(tidy-select)
Selector of columns in x$table_body
(predicate expression)
Predicate expression to select rows in x$table_body.
Review rows argument details.
Updated gtsummary object
# Example 1 ----------------------------------
data.frame(x = FALSE) |>
tbl_summary(type = x ~ "categorical") |>
modify_post_fmt_fun(
fmt_fun = ~ifelse(. == "0 (0%)", "0", .),
columns = all_stat_cols()
)
Characteristic
N = 11
1 n (%)