Git Product home page Git Product logo

tidyr's Introduction

tidyr

CRAN status Travis build status Codecov test coverage

Overview

The goal of tidyr is to help you create tidy data. Tidy data is data where:

  1. Each variable is in a column.
  2. Each observation is a row.
  3. Each value is a cell.

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 time fighting with the tools and more time working on your analysis.

Installation

# The easiest way to get tidyr is to install the whole tidyverse:
install.packages("tidyverse")

# Alternatively, install just tidyr:
install.packages("tidyr")

# Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/tidyr")

Cheatsheet

Getting started

library(tidyr)

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 into multiple columns: it makes “long” data wider.

tidyr also provides separate() and extract() functions which makes it easier to pull apart a column that represents multiple variables. The complement to separate() is unite().

To get started, read the tidy data vignette (vignette("tidy-data")) and check out the demos (demo(package = "tidyr")).

Related work

tidyr replaces reshape2 (2010-2014) and reshape (2005-2010). Somewhat counterintuitively each iteration of the package has done less. tidyr is designed specifically for tidying data, not general reshaping (reshape2), or the general aggregation (reshape).

If you’d like to read more about data reshaping from a CS perspective, I’d recommend the following three papers:

To guide your reading, here’s a translation between the terminology used in different places:

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

Getting help

If you encounter a clear bug, please file a minimal reproducible example on github. For questions and other discussion, please use community.rstudio.com.


Please note that the tidyr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

tidyr's People

Contributors

aaronwolen avatar aneisse avatar artemklevtsov avatar ax42 avatar batpigandme avatar billdenney avatar chuliangxiao avatar colearendt avatar davisvaughan avatar dgrtwo avatar dhimmel avatar dholstius avatar dpananos avatar echasnovski avatar eokodie avatar foundinblank avatar hadley avatar jimhester avatar joshkatz avatar juliasilge avatar krlmlr avatar lionel- avatar lorenzwalthert avatar markdly avatar pierucci avatar rmsharp avatar romainfrancois avatar statisfactions avatar webbedfeet avatar wibeasley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.