add_image: Add plot into a document object

View source: R/image2pptx.R

add_imageR Documentation

Add plot into a document object

Description

Add plot into a document object

Usage

add_image(
  mydoc,
  x = NULL,
  preprocessing = "",
  left = 1,
  top = 2,
  width = 8,
  height = 5.5,
  units = "in",
  res = 300,
  format = "emf",
  ...
)

Arguments

mydoc

A document object

x

An string of R code encoding plot

preprocessing

A string of R code or ""

left

left margin

top

top margin

width

the width of the device.

height

the height of the device.

units

The units in which height and width are given. Can be px (pixels, the default), in (inches), cm or mm.

res

The nominal resolution in ppi which will be recorded in the bitmap file, if a positive integer. Also used for units other than the default, and to convert points to pixels.

format

plot format

...

additional arguments passed to png()

Value

a document object

Examples

require(officer)
require(rrtable)
require(magrittr)
require(ggplot2)
read_pptx() %>% add_text(title="Add image") %>% add_image("plot(iris)")
read_docx() %>% add_text(title="Add image") %>% add_image("plot(1:10)",format="png")

cardiomoon/rrtable documentation built on March 14, 2023, 10:39 p.m.