One cool R package I have been using lately, is ReporteRs. It essentially takes your plots etc and creates a PowerPoint of these. The quality of these are pretty good. This has been really useful for me, as I have been doing a lot of ‘data story boards’ for client presentations. Having a PowerPoint story board of all of my figures allows me to visualise what results I have, and what will be good for a client. If you’re a scientist writing a paper, this package will also come in handy as it will allow you to essentially create a PPT of your plots, diagnostics from these and even tables!
This is the final product here.
#Loading the package require(ReporteRs) #Create dummy variables x=1:200 y=jitter(1:200,50) #Setting up an lm model m=lm(y~x) #Set your working directory setwd() # Create a PowerPoint document. This is just an empty pptx doc at the moment plots = pptx() #Create your first slide. This will be a title slide plots = addSlide(plots, "Section Header") plots = addTitle(plots, "My storyline") #Create a content slide plots = addSlide(plots, "Title and Content") plots = addTitle(plots, "Linear regression diagnostics") #Wrap the plotting functions inside this wrapper. #IMPORTANT. Anything you place in here such as functions, #will not be avialable outside of it. So I suggest just placing #the plotting stuff in here. plotlm.diag= function(){ #So we can have all of the plots on one page par(mfrow=c(2,2)) #Plotting the diagnostics plot(m) } #This adds the plot to our empty plots Title and Content slide plots = addPlot(plots, plotlm.diag,vector.graphic = T) #Create a table output plots = addSlide(plots, "Title and Content") plots = addTitle(plots, "My lm output") #The flextable output of the lm summary plots = addFlexTable(plots, vanilla.table(data.frame("terms"=row.names(data.frame(summary(m)$coefficients)), summary(m)$coefficients))) #Create another content slide plots = addSlide(plots, "Title and Content") plots = addTitle(plots, "My plot") plot1= function(){ plot(x,y) } plots = addPlot(plots, plot1,vector.graphic = T) ####Create PPT writeDoc(plots, file = "mystoryline.pptx")