Writing a thesis in R Markdown

A short discussion about my experiences using R Markdown to write my PhD thesis

Harry Fisher https://hfshr.xyz
03-14-2020

At the start of my PhD I had never even heard of R/R Markdown let alone considered using it to write my thesis. However, thanks in part to the numerous amount of resources out there showing what is possible within R for writing lengthy technical documents, I made the decision to give it a go - and haven’t looked back since.

The purpose of this post is to pay homage to the resources I used throughout writing my PhD and highlight some of the issues I came across while doing so, in the hope that a future reader may find something useful…

My only advice to someone who was considering using R Markdown to write a thesis would be just go for it - there are ample resources out there to help, and the process is incredibly rewarding.

Benefits

Combine text and code

The ability to integrate text and R code in the same document to produce tables and figures is extremely useful. No more copy/pasting from Excel to Word for tables and figures!

Separate files for each chapter

Large word documents can quickly become unwieldy, and increasingly frustrating to work with as the document grows in length. R Markdown lets you easily combine multiple chapters/files into one document when you press knit.

Learn a new skill

I found writing in Markdown really satisfying. Writing a thesis can certainly be a little dull at times, but there were always new things to learn while using Markdown, and this certainly helped keep me motivated when writing wasn’t going so well…

Potential downsides

Comments

This was the only major issue I faced using Markdown. While my supervisors were happy enough for me to use R Markdown, they were not too keen on learning how to use git and start opening pull requests on my draft chapters… So for feedback, I ended up knitting to .docx so comments could be tracked using Microsoft word. The downside to this was that formatting often went astray, but over time they were ok with this after seeing the aesthetically pleasing PDF outputs that were possible.

Inevitably you will need to learn some LaTeX

R markdown does a fantastic job and can get you 95% of the way there without ever having to open a .tex file. However there will likely be some fine tuning that is either not easy or not possible to do with R Markdown, and using If unfamiliar with LaTeX, this can be a steep learning curve, but there are ample resources out there to help figure things out.

Potential to get distracted from writing

Occasionally I would spend time fiddling with the layout of certain pages, or trying to get a specific table looking a certain way, when I really should have just saved that till after the writing was finished. My tip would be dedicate time to writing and time to editing and try not to mix the two. That way you can dedicate your full focus to each task, and not get distracted by one when you need to be working on the other.

Credits

Below are some of the key resources I used during my write up.

Aust, Frederik, and Marius Barth. 2018. Papaja: Create APA Manuscripts with r Markdown. https://github.com/crsh/papaja.
Solomon, Nick. 2020. Thesisdown: An Updated r Markdown Thesis Template Using the Bookdown Package.
Xie, Yihui. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC. https://github.com/rstudio/bookdown.
Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.

References

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Fisher (2020, March 14). Data, Code & Coffee: Writing a thesis in R Markdown. Retrieved from https://hfshr.xyz/posts/2020-03-14-writing-a-thesis-in-r-markdown/

BibTeX citation

@misc{fisher2020writing,
  author = {Fisher, Harry},
  title = {Data, Code & Coffee: Writing a thesis in R Markdown},
  url = {https://hfshr.xyz/posts/2020-03-14-writing-a-thesis-in-r-markdown/},
  year = {2020}
}