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”).
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”)
library(tidyr)
tidyr có 5 loại chính: Chi tiết xem tại đây https://tidyr.tidyverse.org
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