Skip to contents

Single-page convenience wrapper around as_rtftables(): takes a gt_tbl, a gtsummary table, an rtables/tern VTableTree, an rlistings listing_df, a flextable, a huxtable, or a plain data.frame / tibble, and returns one rtftable (rather than a list of pages). It is exactly as_rtftables(x, read_meta = read_meta, split = "none", ...)[[1]].

Usage

as_rtftable(x, read_meta = TRUE, ..., gt_obj)

Arguments

x

A gt_tbl, a gtsummary table, an rtables/tern VTableTree, an rlistings listing_df, a flextable, a huxtable, or a plain data.frame / tibble. A gt_group (gt::gt_group() / gt::gt_split(), or a tfrmt page_plan render) or a gtsummary tbl_split container is accepted when it holds exactly one table; multi-member containers error – convert those with as_rtftables().

read_meta

TRUE (default, read all render-relevant metadata), FALSE (rendered body only), or a character vector of tokens. See as_rtftables().

...

Passed to rtftable() (and on to as_rtftables()). Explicit values always win over the values extracted from the source table.

gt_obj

The old name of x: deprecated in 0.8.x (warns once a session, still works), removed in 0.9.0.

Value

An rtftable S3 object.

Details

The body is the table's rendered body (gt via gt::extract_body(), rtables via formatters::matrix_form()); only render-relevant metadata is read. See as_rtftables() for the full What is carried, by source table – in short: column labels, alignment, spanning headers, widths, titles, footnotes, in-cell footnote marks and (for gt/gtsummary) explicit tab_style() borders and text styles are carried; cell fills, fonts, gt theme borders and Markdown are not.

See also

as_rtftables() for the paginating, list-returning version and the per-source metadata table.

Examples

library(gt)
g <- gt(head(mtcars, 5)) |>
  cols_label(mpg = "MPG", cyl = "Cyl") |>
  cols_align("right", columns = c(mpg, cyl))
tbl <- as_rtftable(g)