Learn R Programming

gt (version 0.7.0)

as_word: Output a gt object as Word

Description

Get the Open Office XML table tag content from a gt_tbl object as as a single-element character vector.

Usage

as_word(
  data,
  align = "center",
  caption_location = c("top", "bottom", "embed"),
  caption_align = "left",
  split = FALSE,
  keep_with_next = TRUE
)

Arguments

data

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

align

left, center (default) or right.

caption_location

top (default), bottom, or embed Indicating if the title and subtitle should be listed above, below, or be embedded in the table

caption_align

left (default), center, or right. Alignment of caption (title and subtitle). Used when caption_location is not "embed".

split

TRUE or FALSE (default) indicating whether activate Word option 'Allow row to break across pages'.

keep_with_next

TRUE (default) or FALSE indicating whether a table should use Word option 'keep rows together' is activated when TRUEd

Function ID

13-5

See Also

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

Examples

Run this code
# Use `gtcars` to create a gt table;
# add a header and then export as
# OOXML code for Word
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_word()

Run the code above in your browser using DataLab