as_rtf: Output a *gt* object as RTF

View source: R/export.R

as_rtfR Documentation

Output a gt object as RTF

Description

Get the RTF content from a gt_tbl object as as a single-element character vector. This object can be used with writeLines() to generate a valid .rtf file that can be opened by RTF readers.

Usage

as_rtf(
  data,
  incl_open = TRUE,
  incl_header = TRUE,
  incl_page_info = TRUE,
  incl_body = TRUE,
  incl_close = TRUE
)

Arguments

data

A table object that is created using the gt() function.

incl_open, incl_close

Options that govern whether the opening or closing "{" and "}" should be included. By default, both options are TRUE.

incl_header

Should the RTF header be included in the output? By default, this is TRUE.

incl_page_info

Should the RTF output include directives for the document pages? This is TRUE by default.

incl_body

An option to include the body of RTF document. By default, this is TRUE.

Examples

Use gtcars to create a gt table. Add a header and then export as RTF code.

tab_rtf <-
  gtcars |>
  dplyr::select(mfr, model) |>
  dplyr::slice(1:2) |>
  gt() |>
  tab_header(
    title = md("Data listing from **gtcars**"),
    subtitle = md("`gtcars` is an R dataset")
  ) |>
  as_rtf()

Function ID

13-4

Function Introduced

v0.2.0.5 (March 31, 2020)

See Also

Other table export functions: as_latex(), as_raw_html(), as_word(), extract_cells(), extract_summary(), gtsave()


gt documentation built on April 3, 2023, 5:18 p.m.