Peter Foley
R Tutorial
Week 1 - Overview and Introduction
This week is just a high-level overview of R and examples of things you'll use it for.

Presentation Slides
Example Code
Diamonds data file (exported from the ggplot2 package)

Week 2 - The R language
We'll cover the various data types and how to manipulate them, loops and conditionals, functions, matrix and array functions, memory management and potential issues. It's too much to absorb in one hour, so I've found some readings that are pretty good.

For most of you, sections 2, 7, and 8 of this PDF will be a good pace and level of detail. It includes a number of exercises that you can do at the end of each chapter, though you might need to install and load the DAAG, MASS, or datasets packages to use the functions and data sets described in the exercises. You can probably do all the problems for 2 and 7 (they're short) and then a random selection from section 8. Feel free to email me if you get stuck on anything.

For those of you who have done a lot of coding in other languages, this file is a very dense summary of how R does things.

Finally, if you're feeling particularly ambitious, you can go through sections 1-10 of this documentation

Presentation Slides
Fake word construction

Week 3 - fitting models
The first half of the tutorial this week will cover how to fit linear, generalized linear, multinomial, ordinal, and mixed models. We'll also cover bootstrapping and simulation.

To prepare for the model-fitting portion, you should read section 5 up to 5.3 (pages 55-61) in this PDF and sections 5 and 9 in this one.

For the bootstrapping portion, you should read this PDF on bootstrapping in R.

Presentation Slides
Example code

Week 4 - graphics
This will be a quick overview of doing basic plotting in R. It's a good idea to read through pages 21 to 30 in this PDF for an introduction to the base graphics, and the R reference card will save you a lot of time searching for common graphics parameters.

For ggplot2, this (skip the first bit) is a short and sweet intro. From on-campus IP's, Hadley Wickham's book on ggplot2 goes into a lot more detail and is handy to download as a reference. He also did a talk a while back with slides and videos linked here.

Presentation Slides
Example code

Week 5 - optimization
R has an immense number of ways to do optimizations. I'll primarily discuss the base tools, maxLik, and rgenoud. It's worth browsing through the CRAN Optimization Task View if you've got real optimization problems. There are tools for dealing with constraints, large optimization problems, global optimization, etc.

Presentation Slides
Example code