PS04: Tidy Data and Joining Tables

Published

May 25, 2026

Overview

Practice reshaping data between wide and long formats with tidyr, and combining data frames using dplyr join functions.

Read Chapter 4 of ModernDive before attempting this problem set.


Download

Download the problem set template, open it in RStudio, and complete the exercises directly in the document.

PS04-template.zip


Setup

Run this at the top of your document to install and load the required packages:

if (!require(pacman)) install.packages("pacman")
pacman::p_load(tidyverse, nycflights13)

Exercises

PS04a: Tidy data with tidyr

Use pivot_longer() and pivot_wider() to reshape data.

PS04b: Joining tables with dplyr

Use inner_join(), left_join(), and other join functions.


When you are done, render to HTML and submit on Moodle. Name your file PS04_yourname.html.