Skip to content
/ tidyr Public
forked from tidyverse/tidyr

Easily tidy data with spread and gather functions.

License

Notifications You must be signed in to change notification settings

tverbeke/tidyr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tidyr

Build Status

tidyr is a reframing of reshape2 designed to accompany the tidy data framework, and to work hand-in-hand with magrittr and dplyr to build a solid pipeline for data analysis.

Just as reshape2 did less than reshape, tidyr does less than reshape2. It's designed specifically for tidying data, not the general reshaping that reshape2 does, or the general aggregation that reshape did. In particular, built-in methods only work for data frames, and tidyr provides no margins or aggregation.

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.

These verbs have a number of synonyms:

tidyr gather spread
reshape(2) melt cast
spreadsheets pivot unpivot
databases fold unfold

tidyr also provides separate() function which makes it easier to turn a single character column into multiple columns either according to regular expression, or by fixed positions. The complement to separate() is unite().

Installation

tidyr is available from CRAN.

The development version can be installed using:

# install.packages("devtools")
devtools::install_github("hadley/tidyr")

Getting started

To get started, read the tidy data vignette (vignette("tidy-data")) and check out the demos/.

Note that tidyr is designed for use in conjunction with dplyr, so you should always load both:

library(tidyr)
library(dplyr)

References

If you'd like to learn more about these data reshaping operators, I'd recommend the following papers:

About

Easily tidy data with spread and gather functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 100.0%