Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export several plots from R into ppt

Tags:

plot

r

powerpoint

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 .

like image 288
user2506015 Avatar asked Mar 12 '23 15:03

user2506015


1 Answers

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" )
like image 101
Batanichek Avatar answered Mar 24 '23 22:03

Batanichek