renderAll: Read Word document and apply functions...

View source: R/renderAll.R

renderAllR Documentation

Read Word document and apply functions body_add_flextables,renderInlineCode,addPlots.

Description

Read Word document and apply functions body_add_flextables,renderInlineCode,addPlots.

Usage

renderAll(
  docxIn,
  docxOut,
  flextables = NULL,
  Plots = NULL,
  height = 6,
  width = 6,
  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

flextables

Named list of flextables; Tables to be inserted into the Word file

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

height

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

width

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

debug

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

Value

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

Examples

library(flextable)
library(ggplot2)
ft_mtcars <- flextable(mtcars)
FT <- list(mtcars=ft_mtcars)
Plots <- list(mtcars1 = ggplot(mtcars, aes(x = wt, y = hp, col = as.factor(cyl))) + geom_point())
renderAll(docxIn=paste0(examplePath(), "templates/templateAll.docx"),
          docxOut=paste0(tempdir(), "/resultsAll.docx"),
          flextables=FT,
          Plots=Plots)


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