I found a function here to create a ppt with a slide for a plot created in R. Here is the link to that function: R: Function to export currently active R plot to Powerpoint/Word/LibreOffice
I would like my program to add several slide (containing one plot each).
I currently use : export2ppt(file="plot.pptx")
But I can't figure out how I add a second plot to the same file .
Try for example
library(ReporteRs)
doc =pptx( ) # create pptx
doc=addSlide(doc,"Title and Content") # add slide
doc<-addTitle(doc,"first") # add title
fun_1<-function(){
plot(mpg ~ wt, data = mtcars)
}
doc <- addPlot(doc, fun= fun_1,vector.graphic =FALSE ) # add plot
doc=addSlide(doc,"Title and Content") # add slide
doc<-addTitle(doc,"Second") # add title
fun_2<-function(){
plot(mpg ~ cyl, data = mtcars)
}
doc <- addPlot(doc, fun= fun_2,vector.graphic =FALSE ) # add plot
writeDoc(doc, "r-2.pptx" )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With