rtf_doc: Create a 'rtf_doc' object

Description Usage Arguments Value rtf_doc Properties See Also Examples

View source: R/rtf_doc.R

Description

This constructs the main object that will be used for an RTF document. The object is composed of a table, titles(s), and footnote(s).

A table contained in the rtf_doc object should be a supported class. The huxtable package is the most supported, however our intention is to support other packages capable of writing RTF tables as well. Currently, it is planned to support the gt package, but the gt package's RTF methods are not functional.

The titles and footnotes are composed of hf_line objects.

See the vignette for a more complete view of intended usage.

Usage

1
rtf_doc(table, titles = list(), footnotes = list(), header_rows = 1)

Arguments

table

A table of a supported class.

titles

A list of hf_line objects containing table titles and associated formatting.

footnotes

A list of hf_line objects containing table footnotes and associated formatting.

header_rows

An integer determining how many rows of the table are column headers. Only used for huxtable tables. Can be set to 0 to disable repeating column headers.

Value

A list with a table, titles, and footnotes component. Class of "rtf_doc" with the properties describled below.

rtf_doc Properties

Document level properties set the defaults and will be used where they are not overridden by hf_line or table properties.

See Also

hf_line

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Adding lines during rtf_doc construction
ht <- huxtable::huxtable(
 column1 = 1:5,
 column2 = letters[1:5]
)
# Set table properties
library(magrittr) #load in a pipe
ht %>%
  huxtable::set_bold(1, 1:ncol(ht), TRUE) %>%
  huxtable::set_escape_contents(TRUE) %>%
  huxtable::set_col_width(c(0.25, 0.75))

rtf <- rtf_doc(ht, titles = list(hf_line("My Header")))
# Set document properties
rtf <- rtf %>%
  set_font_size(15) %>%
  set_ignore_cell_padding(TRUE)

names(rtf)

write_rtf(rtf, file = tempfile())

pharmaRTF documentation built on Sept. 28, 2021, 5:08 p.m.