A quick exploration of the ReporteRs package

The package ReporteRs has been getting some play on the interwebs this week, though it’s actually been around for a while. The nice thing about this package is that it allows writing Word and PowerPoint documents in an OS-independent fashion unlike some earlier packages. It also allows the editing of documents by using bookmarks within the documents.

This quick note is just to remind me that the structure of ReporteRs works beautifully with the piping conventions of magrittr. For example, a report I wrote today maintained my flow while writing R code to create the report.


mydoc <- docx() %>%
  addParagraph(value = 'Correlation matrix', style='Titre2') %>%
  addParagraph(value='Estimates') %>%
  addFlexTable(FlexTable(cormat)) %>%
  addParagraph(value = 'P-values') %>%
  addFlexTable(FlexTable(corpval)) %>%
  addParagraph(value = "Boxplots", style='Titre2') %>%
  addPlot(fun=print, x = plt, height=3, width=5) %>%
  writeDoc(file = 'Report.docx)

Note that plt is a ggplot object and so we actually have to print it rather than just put the object in the addPlot command.

This was my first experience in a while using ReporteRs, and it seemed pretty good to me.



  1. This is an awesome package for those of us living in Powerpoint organizations. I can throw charts and tables into the official corporate template extremely quickly.

    The only issue I have is managing margins around plots that I include in Powerpoint, as a workaround I’ve been plotting to .png files and then inserting the .png into the Powerpoint.

    1. It would, wouldn’t it? I will add that later. The point for this post was that the package is amenable to the piping paradigm that many fans of the Hadleyverse use.

    1. Don’t know. My suspicion would be that you would have to set that up in the template. I’d look in the package documentation.

  2. Could this package be utilized with .txt files to create table in WORD?

    ie Stats summary output.txt fiel and have a Word Table as a final product?
    right now I’m copying/pasting into WORD from my output.txt files

    it would awesome to automate the Table creation and help to avoid copy/paste errors πŸ˜‰

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s