Before class
Plan for today
- What makes data tidy, and why the tidyverse wants it that way
- Wide vs. narrow (long) layouts of the same data
pivot_longer() and pivot_wider()
- Choosing a shape to fit the task
Helpful links
Recap, and what’s new
All week you’ve manipulated data within its existing shape, choosing rows, columns, and groups.
pivot_longer() and pivot_wider() change the shape of the table itself, without changing any of the values.
These come from tidyr, dplyr’s sibling package (both load with library(tidyverse)).
Activity
Activity: reshaping
Roughly 25 minutes. Individually or with a neighbor.
Format: you’ll diagnose whether tables are tidy/wide/narrow, pivot a tiny table by hand-prediction then check, pivot billboard longer and plot it, widen a penguins summary into a comparison table, confirm the two verbs undo each other, and debug a pivot that went “too narrow.”
To turn in: save your .qmd and rendered HTML.
Wrap-up & looking ahead
Tomorrow (Friday): Quiz 3 in the first 20 minutes, then version control, Git and GitHub concepts and a demonstration, so your project team can collaborate on shared code.