Step 3: R primers

Step 3 of 5

Before you start: a web browser. Nothing to install. When you finish: you have written R code and drawn a plot.

5 short pages. Each one has live code cells you edit and run inside the page.

Do them in order. Each page assumes the ones before it.

ImportantOpen these at home

The first page downloads about 17 MB. That is R itself, compiled to run in a browser. Primer 5 draws plots and downloads about 37 MB.

Your browser keeps the download for 7 days. Work through these at home this week and you pay nothing again at IISc.

The 5 primers

1 · Objects, functions, vectors

The 3 ideas the rest of R is built on. ~17 MB

2 · Tibbles

The rectangle you analyse: one row per person, one column per variable. ~21 MB

3 · Packages and the pipe

library(), and the |> that makes code read left to right. ~22 MB

4 · The dplyr verbs

filter, select, mutate, group_by, summarise. Most analysis is these 5. ~22 MB

5 · Your first plot

ggplot2, layer by layer. The heavy page: about 37 MB.

Primer 5 is the heavy one. Do it on a connection you trust.

How to work through a primer

  1. Open the page. Wait for the cells to become ready.
  2. Press Run on every cell, from the top down.
  3. Change a number in a cell and press Run again.
  4. Read what changed, and why.

You should see: output appear under each cell after you press Run.

If it does not work: see the next section.

NoteWhy this matters

Reading code teaches you very little. The cells are there so that you type, get an error, and fix it, before Monday rather than during a session.

Nothing is marked and nothing is recorded. Change whatever you like; you cannot break anything.

Nothing carries from one page to the next either. Each page starts R from scratch.

If the cells never become ready

Wait 2 or 3 minutes first. The page has to download R before anything runs.

If it still does not work:

  1. Try a phone hotspot. Hospital and institutional wifi often block this.
  2. Use a current Chrome, Edge, Firefox or Safari.
  3. Turn off any ad blocker for this site.
  4. Use the R primer reference in RStudio instead. It teaches the same material.

There is no Stop button on these pages. If you write a loop that never ends, reload the page.

Step 3 is done

→ Step 4 of 5: the epidemiology primers

Back to top