The example below demonstrates intermingling of table and text content. This functionality is enabled by the ability to append multiple pieces of content to the same report. Appending content is useful when you want to create a report with multiple tables, or provide textual analysis along with tabular or graphic displays.
library(reporter)
# Create temporary path
<- file.path(tempdir(), "example4.pdf")
tmp
# Dummy text
<- paste0("Lorem ipsum dolor sit amet, consectetur adipiscing elit, ",
cnt "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 text content
<- create_text(cnt, width = 6)
txt
# Prepare data
<- mtcars[1:10, ]
dat
# Create table content
<- create_table(dat) %>%
tbl titles("Table 1.0", "MTCARS Sample Data") %>%
footnotes("* Motor Trend, 1974")
# Create report and add both table and text content
<- create_report(tmp, font_size = 12,
rpt output_type = "PDF") %>%
page_header(left = "Client: Motor Trend", right = "Study: Cars") %>%
add_content(tbl, page_break = FALSE) %>%
add_content(txt) %>%
page_footer(left = Sys.time(),
center = "Confidential",
right = "Page [pg] of [tpg]")
# Write the report
write_report(rpt)
# file.show(tmp)