Week 7 · Tuesday, Nov 10 · 9:50-10:55 am · Self-guided
On your own, no AI:
Keep a script as you go: week07/ds07_notes.R, one heading per exercise, your final answer under each.
Important
3 points: 2 for the PDFs on Canvas, 1 for this afternoon’s check.
?help pages, the lesson pages, Thursday’s slides, your notes, asking meStuck for more than 10 minutes on one exercise? Raise your hand.
Same numbers, different shape. Ask: what does one row stand for?
pivot_longer(): more rows, fewer columns. One row per single measurementpivot_wider(): fewer rows, more columns. The reverselibrary(tidyr) at the top of your script, next to library(dplyr)Before you pivot, predict nrow() and ncol() of the result. 1704 country-years × 3 metrics stacked is how many rows?
At the bottom of week07/ds07_notes.R:
Be specific. “pivots” doesn’t help; “why Exercise 4 gives so many NAs” does. You’ll use it this afternoon.
Canvas: both PDFs by Wednesday 11:59 pm. Printing is optional.
1:30 pm: bring your laptop, charged. You need data/survey_wave2.csv and data/sites.csv from last week.

STAT 266A · Fall 2026 · UC Santa Cruz