Save Input via R markdown.

save_with_rmarkdown(x, path, reference_docx = get_reference_docx("portrait"))

Arguments

x

(gtsummary/gt_tbl/flextable/list)
table object of class 'gtsummary', 'gt_tbl' (gt table) or 'flextable', or a list of table objects.

path

(path)
path to save file to, e.g. "rendered_table.docx"

reference_docx

(path)
Path to reference document that when not NULL is passed to the reference_docx: R markdown field.

output

(string) Output format. For now, only docx output type is supported.

Value

x (invisibly)

Examples

# 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/RtmpxRCBPk/file1e385cad4cc4.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"))
#> Error in seq.default(20, nrow(tbl), by = 20): 'to' must be of length 1