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.
Usage
as_gt(x, include = everything(), return_calls = FALSE, ...)
Arguments
- x
(
gtsummary
)
An object of class `"gtsummary"- include
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()
.- return_calls
Logical. Default is
FALSE
. IfTRUE
, the calls are returned as a list of expressions.- ...
Arguments passed on to
gt::gt(...)
Note
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.
Examples
# 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 (%)