Learn R Programming

rvg (version 0.1.9)

ph_with_vg: add a plot output as vector graphics into a PowerPoint object

Description

produces a vector graphics output from R plot instructions and add the result in a PowerPoint document object produced by read_pptx.

Usage

ph_with_vg(x, code, ggobj = NULL, type = "body", index = 1, ...)

ph_with_vg_at(x, code, ggobj = NULL, left, top, width, height, ...)

Arguments

x

an rpptx object produced by officer::read_pptx

code

plot instructions

ggobj

ggplot objet to print. argument code will be ignored if this argument is supplied.

type

placeholder type

index

placeholder index (integer). This is to be used when a placeholder type is not unique in the current slide, e.g. two placeholders with type 'body'.

...

arguments passed on to dml_pptx.

left, top

left and top origin of the plot on the slide in inches.

height, width

Height and width in inches.

Examples

Run this code
# NOT RUN {
library(officer)
doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with_vg(doc, code = barplot(1:5, col = 2:6), type = "body")
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with_vg_at(doc, code = barplot(1:5, col = 2:6),
  left = 1, top = 2, width = 6, height = 4)
print(doc, target = "vg.pptx")
# }

Run the code above in your browser using DataLab