Sari Nahmad
Sep 8th, 2016

Whether for documentation or reporting, incorporating document producing packages in your R code will allow you to easily share your code and its outputs. Incorporating these methods will improve your productivity especially if the process is iterative or recurring. You will also avoid copying and pasting code and graphs over and over again! Today we will cover a few easy options to get you started. The code is commented to review in further detail.


R Markdown

R Markdown is not a package but a different type of file (.Rmd extension). You can save and execute code while creating reports and only a few adjustments are needed to convert any existing R code to R Markdown. You can start a new R Mardown file by going to File > New File > R Markdown in R Studio. Your code results can be converted to HTML, PDF, or a Word document by pressing the Knit button when your code is ready. One benefit of using R Markdown is that you can put your code in chunks and choose how you want it to display. For example, you can hide code but display its outputs. You can also have plain text and headers at different levels. The R Markdown outputs are also stylistically well done and organized. For reference, here is the R Markdown Guide:



Unlike R Markdown, ReporteRs is a package that can create PowerPoint (as well as Word) documents. The major advantage to ReporteRs is that the images and tables it produces in the documents are editable. It also has an array of options to construct each slide and customize tables. Refer to for more details.


R Markdown Code


(Click to enlarge)

R Markdown Output in Word Document



(Click to enlarge)

ReporteRs Code


(Click to enlarge)

ReporteRs PowerPoint Output


(Click to enlarge)