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

This page will feature slides from our sessions, recordings of the various sessions (for review), 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 computer 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.

The module has 10 sessions, each of 90 minutes. The basic format for a session is:

  • 45 minutes of lecture material. These will be recorded and made available as soon as possible.
  • 30 minutes of exercises for you to try, with others in the class
  • 15 minute discussion of exercises, where the instructors will present possible solutions and answer questions

No exercises for this session
Monday, July 10th
Time Topic Lecture Exercises/Discussion
8:30am-10:00am 1. Introductions, reading in data Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
10:30am-12:00pm 2. More data summary and using functions Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
1:30pm-3:00pm 3. Plotting functions, and formulas Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
3:30pm-5:00pm 4. Adding features to plots Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
Tuesday, July 11th
Time Topic Lecture Exercises/Discussion
8:30am-10:00am 5. Over and over (i.e. loops) Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
10:30am-12:00pm 6. More loops, Control Structures, and Bootstrapping Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], no recording
1:30pm-3:00pm 7. Fitting models Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
3:30pm-5:00pm 8. Introduction to R packages Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
Wednesday, July 12th
Time Topic Lecture Exercises/Discussion
8:30am-10:00am 9. Writing your own functions Slides [.pdf], Code [.R], [recording] Exercises [.docx, .pdf], Key: [.R], [recording]
10:30am-12:00pm 10. The End! Slides [.pdf], [recording]

Some special material for Session 10:


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;