Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.

Reproducible research: An introduction to knitr and RMarkdown

A lightning talk presented by Sahir Bhatnagar (McGill University) at the 2018 R in Montreal conference

Date: Thursday July 5, 2018, 18:00
Slides: The slides used for this presentation can be found here

A short talk presented by Sahir Bhatnagar (McGill University) at the Montréal useR group

Date: Wednesday August 12, 2015, 18:00
Location: Notman House
Slides: The slides used for this presentation can be found here
Material: Click on the Download ZIP button on this page, or fork it, or clone it

A workshop presented by Sahir Bhatnagar (McGill University)

Date: Thursday, May 28, 2015, 13:00-­‐16:00
Location: Purvis Hall, Room 25, McGill University
Slides: The slides used for this presentation can be found here

Sponsored by the CRM Statistics Laboratory and the Montreal Biostatistics Seminar Series

Description: With the ever increasing size of data and complexity of methods required to analyze them, the reproducibility of results is necessary to ensure a high quality of scientific research. In this workshop, we will discuss the main concepts and motivations for reproducible research (RR). Mr. Bhatnagar will then introduce useful tools for RR, including RStudio, knitr, and Markdown. We will work through several examples to see how these tools can be used to perform efficiently common tasks such as writing reports, Beamer presentations, running simulations, repetitive function calls that require single or multiple inputs to be changed, and sharing results. Basic knowledge of R and LaTeX is assumed.

Participants must bring their own laptops, with the following programs and packages installed:

Reproducible Examples

All the examples in this repository are reproducible. To compile please follow these instructions:

  1. For a given directory, open the associated .Rproj file in RStudio
  2. Open the .Rnw corresponding to the name of the folder
  3. In RStudio, make sure files are weaved using knitr (Tools -> Global Options -> Sweave -> Weave .Rnw files using: select knitr in the dropdown menu)
  4. In RStudio, click on Compile PDF or in the R console enter knitr::knit2pdf("*.Rnw") where * is the name of the .Rnw to compile

How Does it work?

  • In each of the folders there is a packages.R file, which automatically tests for required packages, and install them if they are missing from your library
  • There is no need to set any working directories, since you have opened the .Rproj file
  • To be able to compile the slides, you need to have a Perl interpreter installed. If you do not have one, simply comment out knit_hooks$set(crop = hook_pdfcrop) in the setup chunk of the mcgill-knitr.Rnw file




En français

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License


Reproducible research: An introduction to knitr






No releases published


No packages published