Story time with papa Jamie


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

#Create dummy variables

#Setting up an lm model

#Set your working directory

# 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

  #Plotting the diagnostics

#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)),
#Create another content slide
plots = addSlide(plots, "Title and Content")
plots = addTitle(plots, "My plot")

plot1= function(){
plots = addPlot(plots, plot1,vector.graphic = T)

####Create PPT
writeDoc(plots, file = "mystoryline.pptx")

Author: Jamie Samson

I am Head of Data Science and Insights at I am a lover of R and consider myself an Rtist in data visualisations.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s