Reproducible Research Course by Eric C. Anderson for (NOAA/SWFSC)


Learning R Markdown in one Hour

In this session our goal is to:

  1. Learn and use many of the features of Rmarkdown
  2. See how to intermix R code with text
  3. Collaboratively write a document to illustrate how Rmarkdown works

The crazy thing is that, even though Rmarkdown provides an incredibly powerful tool for authoring reproducible research documents, you really can learn most of the fundamentals in about an hour.

Rmarkdown Setup

  • If you completed Assignment 2 you will understand what we are about to be doing.
  • I hope everyone got the email I sent with the directions on getting the repository before you landed in the internet-impoverished conference room at NMFS. If not, here they are again:
    1. Open RStudio
    2. Choose File->New Project
    3. When asked, choose “Create Project from Version Control”
    4. Then when asked choose “Git”
    5. For repository URL use this: https://github.com/eriqande/grandma-recipe.git
    6. Let the project directory be named grandma-recipe
    7. Put it somewhere. I chose my Desktop.
    8. Hit “Create Project” and you should be in business.

A few words about Markdown

  • Designed as a text markup language that would be
    • Simple
    • Expressive
    • Intuitive
    • Capable of conveying intent even without being compiled into HTML or PDF
  • There are many Markdown interpreters. The Rstudio folks have been using pandoc to crunch Markdown into other formats. It provides many useful extensions.
  • Customizations of style are mostly separate from the content.

Mardown as “Reproducibility in Report Generation”

  • One nice thing about Markdown is that if you want to see how someone did something and you can find their R Markdown source then you can just look at it and see what they did.
  • Contrast this to trying to explain to someone how to get a certain type of formatting in MS Word.

Learn this in an hour?!

  • Yes, we really can. It’s simple and intuitive.
  • I’ve prepared a document in Rmarkdown using a lot of its features and now we will go through it together to discuss them.
  • You assignment for next week is to write document using all the same features to describe yourself and your research.

comments powered by Disqus