Week 7: tidyr
Lectures
- 7.1 tidyr: Tidy Data and pivot_longer()(PDF)
- 7.2 tidyr: pivot_wider(), separate(), unite()(PDF)
- tidyr cheat sheet (Posit)
Labs
- Lab 7: Tidying Data(PDF)
- Lab 7 solutions (password)
Additional readings
- R for Data Science: Tidy data
- tidyr: Pivoting
- What They Forgot to Teach You About R: Safe paths
- A tidyverse pivot approach to data preparation
Discussion
- Is a table tidy if each country is one row and 2020, 2021, and 2022 are column names? Why or why not?
- When would
pivot_wider()after a summary help, and when would it make the next ggplot harder?