# Abstract

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.

# Introduction

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:

• Updating figures and tables as we refine our analysis
• Editing our analysis and, in turn, editing our paperâ€™s text
• Managing bibliography sections and in-text citations/references

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:

• Free to use
• Uses text so we can:
• Use version control for
• Tracking changes
• Collaborating
• Edit it with our favorite and most powerful text editors
• Use the command line to for automation

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

• Attractive typesetting for mathematics
• Figures, tables, and captions
• In-text citations
• Bibliographies

# Methods

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.

# Results

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