tidyr

Easily tidy data with spread and gather functions.

  • 所有者: tidyverse/tidyr
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

tidyr

CRAN
status
Travis build
status
R build
status
Codecov test
coverage

Overview

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

  1. Every column is variable.
  2. Every row is an observation.
  3. Every cell is a single value.

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").

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)

tidyr functions fall into five main categories:

  • “Pivotting” which converts between long and wide forms. tidyr 1.0.0
    introduces pivot_longer() and pivot_wider(), replacing the older
    spread() and gather() functions. See vignette("pivot") for
    more details.

  • “Rectangling”, which turns deeply nested lists (as from JSON) into
    tidy tibbles. See unnest_longer(), unnest_wider(), hoist(),
    and vignette("rectangle") for more details.

  • Nesting converts grouped data to a form where each group becomes a
    single row containing a nested data frame, and unnesting does the
    opposite. See nest(), unnest(), and vignette("nest") for more
    details.

  • Splitting and combining character columns. Use separate() and
    extract() to pull a single character column into multiple columns;
    use unite() to combine multiple columns into a single character
    column.

  • Make implicit missing values explicit with complete(); make
    explicit missing values implicit with drop_na(); replace missing
    values with next/previous value with fill(), or a known value with
    replace_na().

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).

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

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.

主要指標

概覽
名稱與所有者tidyverse/tidyr
主編程語言R
編程語言R (語言數: 2)
平台
許可證Other
所有者活动
創建於2014-06-10 14:24:33
推送於2025-06-03 17:08:13
最后一次提交
發布數32
最新版本名稱v1.3.1 (發布於 )
第一版名稱v0.1 (發布於 )
用户参与
星數1.4k
關注者數70
派生數417
提交數1.4k
已啟用問題?
問題數1103
打開的問題數52
拉請求數377
打開的拉請求數8
關閉的拉請求數106
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?