library(reporter)
library(ggplot2)
library(magrittr)
# Create temp file path
tmp <- file.path(tempdir(), "mtcars.rtf")
# Create ggplot
p <- ggplot(mtcars, aes(x=cyl, y=mpg)) + geom_point()
# Create plot object
plt <- create_plot(p, height = 4, width = 8)
rpt <- create_report(tmp, output_type = "RTF") %>%
page_header("Client", "Study: XYZ") %>%
titles("Figure 1.0", "MTCARS Miles per Cylinder Plot") %>%
set_margins(top = 1, bottom = 1) %>%
add_content(plt) %>%
footnotes("* Motor Trend, 1974") %>%
page_footer("Time", "Confidential", "Page [pg] of [tpg]")
# Write out report
write_report(rpt)
# Uncomment to view RTF file
# shell.exec(tmp)
Run the code above in your browser using DataLab