-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
reporter-text.Rmd
69 lines (55 loc) · 2.11 KB
/
reporter-text.Rmd
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: "Example 4: Table and Text"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Example 4: Table and Text}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
### Intermingle Table and Text
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.
```{r eval=FALSE, echo=TRUE}
library(reporter)
# Create temporary path
tmp <- file.path(tempdir(), "example4.pdf")
# Dummy text
cnt <- 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 text content
txt <- create_text(cnt, width = 6)
# Prepare data
dat <- mtcars[1:10, ]
# Create table content
tbl <- create_table(dat) %>%
titles("Table 1.0", "MTCARS Sample Data") %>%
footnotes("* Motor Trend, 1974")
# Create report and add both table and text content
rpt <- create_report(tmp, font_size = 12,
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)
```
<img src="../man/images/e4.png"/>
Next: [Example 5: Spanning Headers](reporter-spanning.html)