Programming with R

The best way to learn how to program is to do something useful, so this introduction to R is built around a common scientific task: data analysis.

Our real goal isn’t to teach you R, but to teach you the basic concepts that all programming depends on. We use R in our lessons because:

  1. we have to use something for examples;
  2. it’s free, well-documented, and runs almost everywhere;
  3. it has a large (and growing) user base among scientists; and
  4. it has a large library of external packages available for performing diverse tasks.

But the two most important things are to use whatever language your colleagues are using, so you can share your work with them easily, and to use that language well.

Prerequisites

An understanding of the concepts of files and directories (including working directory) is required.

Though not required, we often use RStudio when teaching this lesson. You can find our introduction to RStudio here.

Topics

  1. Getting Started
  2. Loading data
  3. Data Structures
  4. Making Functions
  5. Making Loops
  6. Best practices for using R and designing programs
  7. Dynamic reports with knitr

Other Resources

Supplemental lessons