2 · Data wrangling
The analysis workflow, tidy data, importing and reshaping
Before anything can be estimated it has to be read in and reshaped. This topic covers the workflow a data analysis follows, what makes a dataset tidy, and the readr / readxl / dplyr tools you will use in every later exercise.
Slides
| Deck | Covers |
|---|---|
| 🖥 Workflow, tidy data, wrangling | The data-analysis workflow and what makes a dataset tidy |
| 🖥 Wrangling with dplyr | Extended version of the deck above, working through the full dplyr verb set |
| 🖥 Import data | Reading CSV and Excel with readr and readxl; cleaning names with janitor |
Exercise
| Exercise | What you practise |
|---|---|
| 📋 AE03-01 Import, clean, summarise, plot | Reading messy Excel and CSV files, cleaning column names, first summaries and plots |
📦 Download the bundle: ae03-data-wrangling — the RStudio project with all four AE03 exercises and their five datasets.
Workflow and tidy data
Read
- 📖 R4DS Ch. 9 — Wrangle
- 📖 R4DS Ch. 12 — Tidy data
- 📖 Cheat sheet: Data tidying with tidyr
Watch (optional)
- 📺 Tidy data: video + slides
- 📺 Grammar of data wrangling: video + slides
- 📺 Webinar: Data wrangling with R and RStudio
Importing data
Read
- 📖 R4DS Ch. 11 — Data import
- 📖 Cheat sheet: Data import with the tidyverse
- 📖 Package docs: readr · readxl · janitor
Watch (optional)
- 📺 Data types: video + slides
- 📺 Data classes: video + slides
- 📺 Importing data: video + slides
- 📺 Importing and recoding data
- 📺 Webinar: What’s new with readxl?
Wrangling with dplyr
dplyr comes up in every exercise from here on, so there is no separate session for it — use this list to learn it alongside everything else.
Read
- 📖 R4DS Ch. 5 — Data transformation
- 📖 Cheat sheet: Data transformation with dplyr
- 📖 tidyverse/dplyr
Practise
Visualising with ggplot2
Like dplyr, ggplot2 is practised throughout rather than in one session.
Read
- 📖 R4DS Ch. 3 — Data visualisation
- 📖 Cheat sheet: Data visualization with ggplot2
Practise
- Data visualisation basics · Exploratory data analysis
- Bar charts · Histograms · Boxplots and counts
- Scatterplots · Overplotting · Customising plots
Watch (optional)
- 📺 Data and visualisation: video + slides
- 📺 Visualising data with ggplot2: video + slides
- 📺 Webinar: Tidyverse visualization manipulation basics