addPlots: Read Word document with bookmarks and create other Word...

View source: R/addPlots.R

addPlotsR Documentation

Read Word document with bookmarks and create other Word document with rendered plots in place.

Description

This function takes a list of functions creating plots and insert into Word document on places with corresponding bookmarks.

Usage

addPlots(
  docxIn,
  docxOut,
  Plots = list(),
  width = 6,
  height = 6,
  res = 300,
  style = NULL,
  debug = F,
  ...
)

Arguments

docxIn

String of length one; path to Word file with bookmarks OR officer::rdocx object

docxOut

String of length one; path for output Word file or NA

Plots

Named list of functions (or plots - for plots which are stored as objects e.g., ggplot) creating plots to be inserted into the Word file

width

width of the plots in output in inches, either of length 1 (and will be recycled), or same length as Plots

height

height of the plots in output in inches, either of length 1 (and will be recycled), or same length as Plots

res

see res parameter in png

style

see style parameter in body_add_img

debug

Boolean of length one; If True then browser() is called at the beginning of the function

...

Parameters to be sent to other methods (png)

Value

Path to the rendered Word file if the operation was successfull OR officer::rdocx object if docxOut is NA

Examples

library(ggplot2)
Plots<-list(plot1=function()plot(hp~wt,data=mtcars,col=cyl),
 plot2=function()print(ggplot(mtcars,aes(x=wt,y=hp,col=as.factor(cyl)))+geom_point()))
addPlots(
 paste(examplePath(),'templates/templatePlots.docx',sep = ''),
 paste(tempdir(),'/resultPlots.docx',sep = ''),
 Plots,height=4)


WordR documentation built on Jan. 13, 2023, 1:12 a.m.