save_with_rmarkdown.RdSave Input via R markdown.
save_with_rmarkdown(x, path, reference_docx = get_reference_docx("portrait"))(gtsummary/gt_tbl/flextable/list)
table object of class 'gtsummary', 'gt_tbl' (gt table) or 'flextable', or a list
of table objects.
(path)
path to save file to, e.g. "rendered_table.docx"
(path)
Path to reference document that when not NULL is passed to the
reference_docx: R markdown field.
x (invisibly)
# create table
tbl <-
cards::ADAE[1:150,] |>
gtsummary::tbl_hierarchical(
variables = c(AESOC, AETERM),
by = TRTA,
denominator = cards::ADSL,
id = USUBJID,
)
# save as docx
gtsummary::as_flex_table(tbl) |>
save_with_rmarkdown(path = tempfile(fileext = ".docx"))
#> ✔ Writing /tmp/Rtmpopq1VW/file1e521978d6e7.docx
# split the tqble and save paginatted table
gtsummary::tbl_split_by_rows(tbl, row_numbers = seq(20, nrow(tbl), by = 20)) |>
save_with_rmarkdown(path = tempfile(fileext = ".docx"))
#> ✔ Writing /tmp/Rtmpopq1VW/file1e523bbdb7f1.docx