Introduction

A great feature of RStudio is that you can create data-driven documents. That is, documents that use combine text and analysis into a “reproducible” documents. This is done using R Markdown. In other words, it allows you to write all of the text, syntax for the analysis, etc. and keep it in a document. This way you are not bouncing between programs and everything is reproducible. This is ideal if you are using a publicly available data set.


Getting Started

First, you need to install the rmarkdown package using:

install.packages( "rmarkdown" )


Now, let’s take a look at how it works. Open a new R Markdown file using the drop-down menu as shown below:



Then, use the options to pick the type of file you want to create.


Afterwards, click on the knit function in the .Rmd pane:



You did it!


Next Steps

Easy enough right? Great! That was a simple example, there is a lot more you can do. If you are ready to charge forward, then here are some helpful links:


Some Examples

Take a look at the RWorkshop github page. Click on the topics folder.

You will see a .Rmd file for all of the sections we covered today. Let’s look through a few.


Here is another example. Take a look through the Open Criminology Phoenix pages. In particular, take a look at this page examining crime in Phoenix. This page is a .html file that is created using this RMarkdown file.


Questions?



Back to R Workshop page


Please report any needed corrections to the Issues page. Thanks!



Last updated 20 August, 2024