The code below creates a PowerPoint slide with a vector based ggplot-object, this works great.
Now I want the same slide, with graph as image (e.g. PNG, un-editable). I think this was possible using ph_with_gg(plot, resolution) etc., but that's now deprecated.
It can be achieved with copy/paste as image in PowerPoint, but that's tedious. My main reason is large datasets and powerpoint slowing down with too many individual objects.
library(ggplot2)
library(officer)
library(rvg)
library(magrittr)
data(iris)
read_pptx() %>%
add_slide(layout='Title and Content',master='Office Theme') %>%
ph_with('Iris Sepal Dimensions', location = ph_location_type(type="title")) %>%
ph_with(dml( ggobj=
ggplot(iris, aes(x=Sepal.Length,y=Sepal.Width,col=Species)) +
geom_point()), location = ph_location_type(type="body")) %>%
print('iris_presentation.pptx')