Summer Institute in Statistical Genetics, and Statistics and Modeling of Infectious Diseases
Module 3: Introduction to R
Instructors: Ken Rice and Tim Thornton

This page will feature slides from our sessions, recordings of the various 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. All times/dates are Pacfic, i.e. Seattle time.

The module has 10 sessions, each of 80 minutes. The standard format for a session is approximately:

  • 45 minutes of pre-recorded lecture material
  • 25 minutes of exercises for you to try, with small-group "breakout" Zoom sessions available, attended by other class participants, and Teaching Assistants
  • 10 minute discussion of exercises, where the instructors will present possible solutions and answer questions

Please join the module's Slack channel, where you can ask questions and see real-time updates from the instructors and TAs.

Monday, July 13th
Time Topic Lecture Exercises/Discussion
8:00am-9:20am 1. Introductions, reading in data Slides [.pdf], Code [.R], video, ZoomRec Exercises [.docx, .pdf], ZoomRec Key: [.R]
9:40am-11am 2. More data summary and using functions Slides [.pdf], Code [.R], video Exercises [.docx, .pdf], ZoomRec Key: [.R]
11:30am-12:50pm 3. Plotting functions, and formulas Slides [.pdf], Code [.R], video Exercises [.docx, .pdf], ZoomRec Key: [.R]
1:10pm-2:30pm 4. Adding features to plots Slides [.pdf], Code [.R], video Exercises [.docx, .pdf], ZoomRec Key: [.R]
Tuesday, July 14th
Time Topic Lecture Exercises/Discussion
8:00am-9:20am 5. Over and over (i.e. loops) Slides [.pdf], Code [.R], video Exercises [.docx, .pdf] ZoomRec Key: [.R]
9:40am-11am 6. More loops, Control Structures, and Bootstrapping Slides [.pdf], Code [.R], video Exercises [.docx, .pdf] ZoomRec Key: [.R]
11:30am-12:50pm 7. Fitting models Slides [.pdf], Code [.R], video Exercises [.docx, .pdf] ZoomRec Key: [.R]
1:10pm-2:30pm 8. Introduction to R packages Slides [.pdf], Code [.R], video1 video2 Exercises [.docx, .pdf] ZoomRec Key: [.R]
Wednesday, July 15th
Time Topic Lecture Exercises/Discussion
8:00am-9:20am 9. Writing your own functions Slides [.pdf], Code [.R], video Exercises [.docx, .pdf] ZoomRec Key: [.R]
9:40am-11am 10. The End! Slides [.pdf], resources below ZoomRec, whole session

Some special material for Session 10:

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;