Converting to Tidy Data

Learn how to covert data into tidy format.

We'll cover the following

We’ve only seen data frames that were already in tidy format. Furthermore, we’ll mostly only see data frames that are already in tidy format as well. However, this isn’t always the case with all datasets in the world. If our original data frame is in wide (non-tidy) format and we’d like to use the ggplot2 or dplyr packages, we’ll first have to convert it to tidy format. We recommend using the pivot_longer() function in the tidyr package (Wickham and Henry, 2019).

Going back to our drinks_smaller data frame from earlier:

Get hands-on with 1200+ tech skills courses.