create_text: Create text content

Description Usage Arguments Details Value See Also Examples

View source: R/text_spec.R

Description

Function to create a text specification that can be added as content to a report. The function creates an S3 object of class 'text_spec'. The create_text function can be used to include analysis on a statistical report.

Usage

1
create_text(txt, width = NULL, align = "left")

Arguments

txt

The text to create.

width

The width of the text in the specified units of measure. If no width is specified, the full page width will be used.

align

How to align the text on the page. Valid values are 'left', 'right', 'center', or 'centre'. Default is 'left'.

Details

To add plain text to a report, use the create_text function. The function allows you to set a width and alignment for the text. The function will preserve any other formatting you apply to the text. See the add_content function to control page breaking and blanks spaces above or below the text.

The text specification also accepts titles and footnotes. See the titles and footnotes functions for further details.

Value

The text specification.

See Also

titles to add a title block to the text, footnotes to add footnotes, and add_content to add the text object to a report.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
library(rptr)
library(magrittr)

# Create temp file path
tmp <- file.path(tempdir(), "mtcars.txt")

# Create dummy text
dt <- paste0("Lorem ipsum dolor sit amet, consectetur adipiscing elit, ",
  "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ",
  "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris ",
  "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in ", 
  "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla ",
  "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa ",
  "qui officia deserunt mollit anim id est laborum.")

# Create the text object
txt <- create_text(dt) %>% 
  titles("Text Content 1.0", "Sample Text Report") %>% 
  footnotes("* Cicero, 1st century BCE")

# Create the report object
rpt <- create_report(tmp, orientation = "portrait") %>% 
  add_content(txt) 

# Write the report to the file system
write_report(rpt)

# Write the report to console
writeLines(readLines(tmp))

#                                Text Content 1.0
#                               Sample Text Report
# 
# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
# incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
# nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
# Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
# eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt
# in culpa qui officia deserunt mollit anim id est laborum.
# 
# * Cicero, 1st century BCE
#

dbosak01/reporter documentation built on Sept. 22, 2020, 3:34 p.m.