anyplot <- dml(code = barplot(1:5, col = 2:6), bg = "wheat")
library(officer)
doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with(doc, anyplot, location = ph_location_fullsize())
fileout <- tempfile(fileext = ".pptx")
print(doc, target = fileout)
Run the code above in your browser using DataLab