Overview

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 time fighting with the tools and more time working on your analysis. Learn more about tidy data in vignette(“tidy-data”).

2. Installation

3. Cheatsheet

4. Usage

library(tidyr)

data.table provides high-performance implementations of melt() and dcast()

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

tibble(version = c("tidyr1.0.0","tidyr < 1.0.0","reshape(2)","spreadsheets","databases"),
       longer = c("pivot longer","gather","melt",   "unpivot",  "fold"),
       wider = c("pivot wider","spread","cast","pivot","unfold"),
) -> Huyen

Huyen
## # A tibble: 5 × 3
##   version       longer       wider      
##   <chr>         <chr>        <chr>      
## 1 tidyr1.0.0    pivot longer pivot wider
## 2 tidyr < 1.0.0 gather       spread     
## 3 reshape(2)    melt         cast       
## 4 spreadsheets  unpivot      pivot      
## 5 databases     fold         unfold