From the course: Cleaning Bad Data in R
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Making long data sets wide
- [Instructor] While data scientists often find themselves needing to take a wide dataset and make it longer, they sometimes need to perform the reverse operation and make a long dataset wider. Earlier in this course I showed you a Mexican Weather dataset and walked you through an example of making it tidier. At one point in the process, I had the intermediate result. I had two temperature records for each weather station on each date. One row contained the maximum temperature for that date while the other contained the minimum temperature. These are really two different values, the maximum and the minimum, for the same observation, temperature over the course of the day. To make this dataset tidy, I want to combine the two rows for the same date and station into a single row. The tidier library within the tidyverse contains a function called spread that takes a long dataset and makes it wide by spreading the information from different rows across columns. The spread function performs…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.