I really like using R (R Core Team 2015) for science because of tools like RStudio (RStudio Team 2015) and RMarkdown (RMarkdown Team 2015). This document is a quick demonstration of writing an academic paper in RMarkdown. There’s a lot of other resources available on the web but hopefully you’ll find this document useful as an example.


Writing reports and academic papers is a ton of work but a large amount of that work can be spent doing monotonous tasks such as:

These monotonous tasks are also highly error-prone. With RMarkdown, we can close the loop, so to speak, between our analysis and our manuscript because the manuscript can become the analysis.

As an alternative to Microsoft Word, RMarkdown provides some advantages:

The rest of this document will show how we get some of the features we need such as:


Our analysis will be pretty simple. We’ll use the diamonds dataset from the ggplot2 (Wickham 2009) package and run a simple linear model. At the top of this document, we started with a code chunk with echo=FALSE set as a chunk option so that we can load the ggplot2 package and diamonds dataset without outputting anything to the screen.

For our analysis, we’ll create a really great plot which really shows the relationship between price and carat and shows how we include plots in our document. Then we’ll run a linear model of the form \(y = mx + b\) on the relationship between price and carat and shows how we include tables in our document. We can also put some more advanced math in our paper and it will be beautifully typeset:

\[\sum_{i=1}^{N}{log(i) + \frac{\omega}{x}}\]

We can also use R itself to generate bibliographic entries for the packages we use so we can give proper credit when we use other peoples’ packages in our analysis. Here we cite the ggplot2 package:

And then we just place that in our .bibtex file.


The plot we made was really great (Figure 1).