Knitting Club: R Markdown for beginners

A person using knitting needles as a peripheral for a knitting computer program onscreen.

Knitting simulator by Kara Stone and Gabby DaRienzo (via Giphy)


I made a couple of training resources about R Markdown for reproducibility:

Click the resource names to jump straight to those sections.


It’s often important to recreate and verify prior work, as well as update it in future as data changes. In government we’re using a code-based approach called Reproducible Analytical Pipelines (RAP) to automate and make reproducible our statistical publications; speeding up our work while reducing error and building confidence.

R has many packages that help with reproducibility. Take a look at the CRAN Task View for some examples.

R Markdown is a particularly useful and ubiquitous tool. It allows you to execute R code inside your document and ‘knit’ it into a readable report with the {knitr} package by Yihui Xie. You can re-run the code, or alter the parameters and re-knit it without stress. This is much faster and less error-prone versus a workflow that moves data between a database, spreadsheet and word processor.

The R Markdown bible has been released recently by Yihui Xie, JJ Allaire and Garrett Grolemund and is the go-to resource for creating reports, presentations, dashboards, websites, books and blogs in R Markdown.


I made some short resources earlier in the year to help beginners in my organisation learn about R Markdown. They’re a little rough, but got the job done. I’m unlikely to update them in future, but you can go to the source on GitHub and leave an issue, or make a pull request.

Knitting Club

Knitting Club is a document about R Markdown and {knitr} made with R markdown and {knitr}. It’s freely available on the web and you can find the code on GitHub.

I presented this document in a cross-department Coffee & Coding session in April 2018. The blurb was:

Do you have woolly knowledge of document creation in R? Needle little help? Matt Dray will drop some purls of wisdom and unravel a yarn about the knitty-gritty of R Markdown and the ‘knitr’ package for one-click document creation. Don’t get the point? If a deadline is looming, you’ll avoid a stitch-up from endless re-running of code and copy-pasting of outputs into a Word document. Come along and have a ball!


Quick R Markdown

If the Knitting Club document is too long, you can check out this shorter slide-based introduction to R Markdown below. You can also access the slides alone and find the source on GitHub.