[This article was first published on R – Win-Vector Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
From https://twitter.com/sharon000/status/1107771331012108288:
From https://tidyr.tidyverse.org/dev/articles/pivot.html:
There are two important new features inspired by other R packages that have been advancing of reshaping in R:
- The reshaping operation can be specified with a data frame that describes precisely how metadata stored in column names becomes data variables (and vice versa). This is inspired by the
cdata
package by John Mount and Nina Zumel. For simple uses ofpivot_long()
andpivot_wide()
, this specification is implicit, but for more complex cases it is useful to make it explicit, and operate on the specification data frame usingdplyr
andtidyr
.- pivot_long() can work with multiple value variables that may have different types. This is inspired by the enhanced
melt()
anddcast()
functions provided by thedata.table
package by Matt Dowle and Arun Srinivasan.
If you want to work in the above way we suggest giving our cdata
package a try. We named the functions pivot_to_rowrecs
and unpivot_to_blocks
. The idea was: by emphasizing the record structure one might eventually internalize what the transforms are doing. On the way to that we have a lot of documentation and tutorials.
- Block Records and Row Records
- Designing Transforms for Data Reshaping with cdata
- Coordinatized Data: A Fluid Data Specification
- Fluid Data
To leave a comment for the author, please follow the link and comment on their blog: R – Win-Vector Blog.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.