Function converts a gtsummary object to a "gt_tbl" object,
that is, a table created with gt::gt().
Function is used in the background when the results are printed or knit.
A user can use this function if they wish to add customized formatting
available via the gt package.
as_gt(x, include = everything(), return_calls = FALSE, ...)(gtsummary)
An object of class "gtsummary"
Commands to include in output. Input may be a vector of
quoted or unquoted names. tidyselect and gtsummary select helper
functions are also accepted.
Default is everything().
Logical. Default is FALSE. If TRUE, the calls are returned
as a list of expressions.
Arguments passed on to gt::gt(...)
A gt_tbl object
As of 2024-08-15, line breaks (e.g. '\n') do not render properly for PDF output.
For now, these line breaks are stripped when rendering to PDF with Quarto and R markdown.
# Example 1 ----------------------------------
trial |>
tbl_summary(by = trt, include = c(age, grade, response)) |>
as_gt()
Characteristic
Drug A
N = 981
Drug B
N = 1021
1 Median (Q1, Q3); n (%)