The goal of tidyr is to help you create tidy data. Tidy data is data where:
Tidy data describes a standard way of storing data that is used wherever possible throughout the tidyverse. If you ensure that your data is tidy, you’ll spend less timing fighting with the tools and more time working on your analysis.
There are two fundamental verbs of data tidying:
gather() takes multiple columns, and gathers them into key-value pairs: it makes “wide” data longer.
spread(). takes two columns (key & value) and spreads in to multiple columns, it makes “long” data wider.
To get started, read the tidy data vignette (
vignette("tidy-data")) and check out the demos,
demo(package = "tidyr")).