This is a lesson on tidying data, remixed from Jenny Bryan’s similar lesson using “Lord of the Rings” data. Most text + code is Jenny’s, basically we plopped a new dataset in there 😉
Specifically, what to do when a conceptual variable is spread out over multiple data frames and across 2 or more variables in a data frame.
gather()
from the tidyr
package. Includes references, resources, and exercises.
spread()
from the tidyr
package. This might be useful at the end of an analysis, for preparing figures or tables.