The R Markdown
Senior Thesis Template

Reed T-Watchers Training


Chester Ismay (cismay@reed.edu)

February 12, 2016

Slides available at http://rpubs.com/cismay/twatchers_2k16_rmd

Why this template was needed

Traditional approach to writing a senior thesis
involving statistical analysis

The dreaded copy-and-paste

  • Import data set into statistical software package
  • Run the procedure to get results
  • Copy and paste appropriate pieces from the analysis into document editor
  • Add descriptions
  • Finish/submit report

Disadvantages of this process

  • Lots of manual work (prone to make errors)
  • Tedious (who likes to carefully copy-and-paste?)
  • Likely not recordable (did you write down all the steps you followed to get your analysis?)
  • What if you made an error at the beginning of your analysis? If your data had an error?

Reproducible research

“Reproducible research is the idea that data analyses, and more generally, scientific claims, are published with their data and software code so that others may verify the findings and build upon them.”

  • Roger Peng, Johns Hopkins

Why would reproducible research be
of value with senior theses?

  • Updating your code at the very beginning has little impact on all of your analysis throughout the rest of the document
  • Helps you remember how you performed your analysis YEARS down the road
  • Gets you prepared for submitting journal articles that may require revisions
  • Assists in others building off/from your work
  • Tech companies are moving more and more towards reproducible research/analysis to help with employee turnover

What is Markdown?

  • A “plaintext formatting syntax”
  • Type in plain text, render to more complex formats
  • One step beyond writing a txt file
  • Render to HTML, PDF, etc.

What does it look like?

  # Header 1
  
  ## Header 2
  
  Normal paragraphs of text go here.
  
  **I'm bold**
  
  [links!](http://rstudio.com)
  
   * Unordered
   * Lists   
   
  And  Tables
  ---- -------
  Like This
  
markdown

What is RMarkdown?

  • “Literate programming”
  • Embed R code in a Markdown document
  • Renders textual output along with graphics

```{r}
x <- rnorm(1000)
length(x)
qplot(x, bins = 10, 
      fill = I("orange"), 
      color = I("black"))
```
## [1] 1000

But then I have to learn R…

Tools to make working with R friendly

  • RStudio is a powerful user interface that helps you get better control of your analysis.
  • Like R, it is also completely free.
  • You can write your entire paper/report (text, code, analysis, graphics, etc.) all in RMarkdown.
  • If you need to update any of your code, RMarkdown will automatically update your plots and output of your analysis and will create an updated PDF file.
  • No more copy-and-paste!
  • It’s my job!

What formats can RMarkdown output to?

rmd pipeline

The Reed College
RMarkdown
Senior Thesis Template

Using predefined templates

  • The actual PDF that is produced via RMarkdown uses the existing \(\LaTeX\,\) template
    • This is to keep the formatting to match what has been approved
  • You don’t need to know any \(\LaTeX\,\) to write your thesis now
    • Except for entering equations like \(Y = mX + b\) which requires you to use the dollar signs
    • For example, $Y = mX + b$

Demo of getting
the template
up-and-running

(Following along with blog here)

When am I available?

  • Email me at cismay@reed.edu or chester.ismay@reed.edu to schedule a time to meet if office hours don’t work
  • Tentative Spring 2016 office (ETC 223) hours
    • Mondays (10 AM to 11 AM)
    • Wednesdays (1:30 PM to 2:30 PM)
  • Sometimes available for virtual office hours via Google Hangouts (email me for details)

Resources

Markdown Cheatsheet

R Markdown Reference Guide

My reedtemplates package

Thanks!


cismay@reed.edu