ph_with_gg

0th

Percentile

add ggplot to a pptx presentation

add a ggplot as a png image into an rpptx object This function will be deprecated in favor of ph_with in the next release.

Usage
ph_with_gg(x, value, type = "body", index = 1, width = NULL,
  height = NULL, location = NULL, ...)

ph_with_gg_at(x, value, width, height, left, top, ...)

Arguments
x

a pptx device

value

ggplot object

type

placeholder type (i.e. 'body', 'title')

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', the first one will be added with index 1 and the second one with index 2. It is recommanded to use argument location instead of type and index.

width, height

image size in inches

location

a placeholder location object. This is a convenient argument that can replace usage of arguments type and index. See ph_location_type, ph_location, ph_location_label, ph_location_left, ph_location_right, ph_location_fullsize.

...

Arguments to be passed to png function.

left, top

location of the new shape on the slide

Aliases
  • ph_with_gg
  • ph_with_gg_at
Examples
# NOT RUN {
if( require("ggplot2") ){
  doc <- read_pptx()
  doc <- add_slide(doc, layout = "Title and Content",
    master = "Office Theme")

  gg_plot <- ggplot(data = iris ) +
    geom_point(mapping = aes(Sepal.Length, Petal.Length), size = 3) +
    theme_minimal()

  if( capabilities(what = "png") ){
    doc <- ph_with_gg(doc, value = gg_plot )
    doc <- ph_with_gg_at(doc, value = gg_plot,
      height = 4, width = 8, left = 4, top = 4 )
  }

  print(doc, target = tempfile(fileext = ".pptx"))
}
# }
Documentation reproduced from package officer, version 0.3.5, License: GPL-3

Community examples

Looks like there are no examples yet.