Setup
Do this before the first session — it takes about 30 minutes
Setup problems take a long time to fix during class, so please get ready before the first session. Each checklist ends with a test: if it prints the expected answer, you’re ready.
Before Session 1 (one-time setup)
Install R (version 4.2 or newer) from CRAN.
Install Positron (free) from Posit. Positron is the program you write and run R code in. Install R first (step 1), then Positron.
Download the workshop folder from GitHub. The files you’ll work with (student scripts, solutions, and data) are stored on GitHub, not on this website. This one download has everything for all eight sessions (under 1 MB).
⬇ Download the workshop folder (cwml-r-workshop.zip)
- The download comes from the workshop’s GitHub page. You don’t need a GitHub account.
- Unzip the file somewhere easy to find (Documents, not Downloads). You get a folder called
cwml-r-workshop.
Open the workshop folder in Positron: open Positron, choose File → Open Folder…, select the unzipped
cwml-r-workshopfolder, and click Open. If Positron asks whether you trust the authors of the files, click Yes.- The workshop files appear in the Explorer on the left.
- An R Console starts at the bottom. If it doesn’t, click the interpreter button in the top-right corner and choose R.
Install the packages. Copy this into the Console (bottom) and press Enter:
install.packages(c("tidyverse", "here", "rio", "janitor", "skimr", "gtsummary", "flextable", "scales"))It can take 5–10 minutes. If you see errors about compilers, see Troubleshooting.
Test it. Copy this into the Console and press Enter:
library(tidyverse); library(here); library(rio); library(janitor); library(skimr); library(gtsummary); library(flextable) nrow(import(here("raw_data", "measles_raw.csv")))
[1] 1215
Red messages that don’t start with “Error” are normal. If you see an error, contact the instructor before the session.
Before every session (2 minutes)
- Open the workshop folder in Positron (File → Open Recent lists it) — not a script on its own
- Open that session’s student script from the
student_scripts/folder - Copy that session’s test into the Console and press Enter:
Session 1 — have ready: the one-time setup above. Test: step 6 above. ✅ Ready if it prints [1] 1215
Session 2 — have ready: your measles problem list from Session 1.
sapply(c("linelist_raw.xlsx", "measles_raw.csv"), \(f) nrow(rio::import(here::here("raw_data", f))))✅ Ready if it prints 6604 and 1215
Session 3 — have ready: linelist_clean.rds and measles_clean.rds, which you saved in Session 2.
sapply(c("linelist_clean.rds", "measles_clean.rds"), \(f) nrow(rio::import(here::here("processed_data", f), trust = TRUE)))✅ Ready if it prints 6604 and 1215
Sessions 4–8 (Session 8 is optional) — have ready: combined_linelist.rds and measles_final.rds, which you saved in Session 3.
sapply(c("combined_linelist.rds", "measles_final.rds"), \(f) nrow(rio::import(here::here("processed_data", f), trust = TRUE)))✅ Ready if it prints 6451 and 1163
Every file a session starts from is already in the processed_data/ folder. When you save your own version in class, it replaces that copy. If yours stops working, download the workshop folder again and copy the file back into processed_data/.
Put the file in the raw_data/ folder before the session. Every lesson ends with a ⭐ BONUS for your own data.
What’s in the workshop folder
cwml-r-workshop/
├── student_scripts/ # student scripts, one per session
├── solutions/ # the student scripts with every answer filled in
├── raw_data/ # the original data files (never edit these!)
├── processed_data/ # cleaned data saved during the sessions
├── outputs/ # plots and tables you save
└── README.md # how to open the folder