Advanced Data Wrangling

Learn advanced data wrangling techniques.

Spreading and gathering data

We can calculate means or other summary statistics on our dataset by adding row after row to our summarize() function. However, when we’re doing the same calculation on many columns, it may be more beneficial to use the gather() and spread() functions to change the shape of our dataset. These two functions will be very useful!


Let’s discuss what gathering our data means. Essentially, we want to take the data in a bunch of columns and put them into two columns (highlighted columns), one containing what used to be the column names and the other having the data that was in the columns. Thus, we end up with one column of categorical data, called the key (the former column headings), and one of the numerical data, called the value (the values in each column).

Get hands-on with 1200+ tech skills courses.