Chapter 1 Introduction

1.1 A preliminary guide

This is a non-exhaustive guide to writing your dissertation using RMarkdown and Bookdown. Specifically, it will walk you through one method of organziing, writing, and rendering a dissertation with these tools, using an adapted version of the Western University thesis templates. This tutorial was written by me, Thea Knowles. At the time of writing, I am currently in the throes of dissertating. This means that there are likely several details I haven’t quite hammered out yet, or techniques I’ve missed. In the last year and a half, I’ve been collecting other people’s tutorials and resources on using RMarkdown + for the purposes of using it to write a dissertation. The final product is my interpretation of these resources, adapted to my needs, and presented here as a “What-I’ve-learned-so-far”-style tutorial.

1.2 Setting up

In order to use this tutorial, you need the following:

  • R
  • RStudio
    • Recent versions of RStudio also include Pandoc, which is required to compile documents
  • Latex for Mac or Windows (if you want to compile to PDF).
    • Alternatively, install TinyTex, the Latex distribution created and recommended by Yihui Xie, creator of RMarkdown and bookdown1.
  • R packages:
if(!require(devtools))
  install.packages("devtools", repos = "http://cran.rstudio.com")
install.packages("bookdown")
install.packages("knitr")

1.3 My process so far

  1. ✏️ Keep notes in a separate bookdown project. This also helped me cut my teeth on bookdown, and made my notes wayyyyy easier to sift through than previous attempts (Google Docs, actual notebooks, txt files, readmes… I have found a lot of ways to flail)

  2. 🗒 Get some data in a .csv file

  3. 🧹 R file #1: load, tidy, and explore data

  4. 📈 R file #2: stats and prep data for use in text, sourcing the work done in R file #1.

  5. 📖 Rmd file: Write up results! Figures coded in text. Stats reported from final models defined in R file #2, with help from predefined functions and code snippets.

    • This does not have to be a complete chapter. It can be part of a chapter. How modular you want to get is really up to you.
  6. 💻 Preview dissertation for myself in an .html format (compiles faster, easier to navigate, and I save it to my Chrome bookmarks for quick access)

  7. 📝 Preview multiple .Rmd files in Word to send to my supervisor as .docx

    • previews/tmp_preview.Rmd uses child files to knit together a subset of my .Rmd files to send to my supervisor
    • There is also a “preview” function with Bookdown, but I haven’t been using this (you could though!)
  8. 📚 When happy, compile the whole dissertation with what I have so far

    • Ensures that I am able to notice and fix any compiling errors at the interim stages and makes me feel like I am making real progress

  1. TinyTex is probably the best way to go because Yihui always anticipates the problems we will run into, but I personally have not used it.