Research Design Seminar

Getting started with R

Research Design for Causal Inference

Congratulations! You're getting started with R.

First things first: before our tutorial session, please:


The objective of this session is to provide you with a brief orientation to R. By the end, you should feel more comfortable interacting with R; independently acquire skills to help you complete the first problem set; evaluate your progress acquiring those skills; and posses the ability to learn more on your own.

The Plan

Below are are a list of the critical skills (divided into three "modules") you should aim to learn in order to be able to use R to complete problem sets (don't worry, many of these skills are very quick!). Each module has a separate page that contains more detailed information and example code (apologies, these separate pages also look different from the rest of the site at the moment). In some cases, the skills are self-explanatory --- either you can complete them successfully or not. Where necessary, I have provided you with some tasks/tests that you can use to assess whether you "get it" or not.

The big idea here is that you can start working through these modules or another tutorial (really any tutorial or example code will do) at your own pace and, whenever you're ready, assess your ability to perform the tasks listed in the modules. If you prefer, you can also just skip around and focus on the stuff you don't immediately understand. It's up to you.

Module A — Interacting with R
  1. Install R as well as an Interactive Development Environment (IDE) such as RStudio.
  2. Run a command in the R console directly. Run a command through a script.
  3. Lookup help and documentation.
  4. Install and load "packages" (also known as "libraries").
  5. Find and change your working directory.
  6. Load a data file (either .RData or .csv).
  7. Know what's in your workspace.
Module B — Fundamental functions & operators
  1. Do some basic math problems.
  2. Assign values to objects (you can use either the = operator or the <- operator).
  3. Identify and change ("cast") the class of an object.
  4. Basic operations with different data structures (e.g., vectors, matrices, and data frames).
  5. Inspect and describe data frames.
  6. Calculate some descriptive statistics and transform variables.
Module C — Slightly more advanced functions & operators
  1. Generate a sequence.
  2. Generate a vector by repeating some numbers.
  3. Index into a variable or a data frame.
  4. Analyze subsets of a dataframe (make sure to load the problem set data again).
  5. Run and summarize a linear regression.
  6. Run a loop.
  7. Use a vectorized function like tapply().