Winter Institute in Statistical Genetics
Module 1: Introduction to R
Instructors: Ken Rice and David Reif

This page will feature slides from our sessions, exercises for you to complete, and their solutions (all to follow). Prior to the module, please install up-to-date versions of R and RStudio on the laptop you will use during the summer institute. Both are free.

Slides and exercises

Script files are posted following each session; these will contain our R code for the exercises. To make them work on your computer, remember to modify file names and locations appropriately. Also note that many different 'correct' solutions are possible.

Session 1, Introductions, reading in data. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 2, More data summary and using functions. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 3, Plotting functions, and formulas. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 4, Adding features to plots. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 5, Over and over. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 6, More loops, Control Structures, and Bootstrapping. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 7, Fitting models. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 8, Introduction to R packages. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 9, Writing functions. Code from the slides [.R] Exercises [.docx, .pdf] (R script file)

Session 10, The End! No exercises for this session

  • David's markdown material:
    • Installation Instructions [.txt]
    • Markdown file [.Rmd] - can be opened in RStudio
    • PDF output file [.pdf]
    • HTML output file [.html]
  • Script files ui.R, server.R and data file for the shiny/salary example. This app is available online
  • Shiny's gallery shows much more functionality than we have time to mention

For easier searching, here are all the slides in one document (PDF).


Datasets - in alphabetical order

Before trying to read data into your R session, we recommend looking at it first, in a text editor. Is the data comma- or tab-delimited? Does it have a 'header' row containing variable names?


Other resources

Some recommended books;