Function converts a gtsummary object to a huxtable object. A user can use this function if they wish to add customized formatting available via the huxtable functions. The huxtable package supports output to PDF via LaTeX, as well as HTML and Word.
as_hux_table(x, include = everything(), return_calls = FALSE)
as_hux_xlsx(x, file, include = everything(), bold_header_rows = TRUE)
(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.
File path for the output.
(scalar logical
)
logical indicating whether to bold header rows. Default is TRUE
A {huxtable} object
Use the as_hux_xlsx()
function to save a copy of the table in an excel file.
The file is saved using huxtable::quick_xlsx()
.
trial |>
tbl_summary(by = trt, include = c(age, grade)) |>
add_p() |>
as_hux_table()
#> Characteristic Drug AN = 98 Drug BN = 102 p-value
#> ───────────────────────────────────────────────────────────
#> Age 46 (37, 60) 48 (39, 56) 0.7
#> Unknown 7 4
#> Grade 0.9
#> I 35 (36%) 33 (32%)
#> II 32 (33%) 36 (35%)
#> III 31 (32%) 33 (32%)
#> ───────────────────────────────────────────────────────────
#> Median (Q1, Q3); n (%)
#> Wilcoxon rank sum test; Pearson's Chi-squared
#> test
#>
#> Column names: label, stat_1, stat_2, p.value