Skip to content

GreenwoodLab/knitr-tutorial

 
 

Repository files navigation

Reproducible research: An introduction to knitr

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

References

Books

Websites

About

Reproducible research: An introduction to knitr

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 98.9%
  • Other 1.1%