reshape2 v1.4.2

0

Monthly downloads

0th

Percentile

by Hadley Wickham

Flexibly Reshape Data: A Reboot of the Reshape Package

Flexibly restructure and aggregate data using just two functions: melt and 'dcast' (or 'acast').

Readme

Reshape2

Build Status

Reshape2 is a reboot of the reshape package. It's been over five years since the first release of reshape, and in that time I've learned a tremendous amount about R programming, and how to work with data in R. Reshape2 uses that knowledge to make a new package for reshaping data that is much more focused and much much faster.

This version improves speed at the cost of functionality, so I have renamed it to reshape2 to avoid causing problems for existing users. Based on user feedback I may reintroduce some of these features.

What's new in reshape2:

  • considerably faster and more memory efficient thanks to a much better underlying algorithm that uses the power and speed of subsetting to the fullest extent, in most cases only making a single copy of the data.

  • cast is replaced by two functions depending on the output type: dcast produces data frames, and acast produces matrices/arrays.

  • multidimensional margins are now possible: grand_row and grand_col have been dropped: now the name of the margin refers to the variable that has its value set to (all).

  • some features have been removed such as the | cast operator, and the ability to return multiple values from an aggregation function. I'm reasonably sure both these operations are better performed by plyr.

  • a new cast syntax which allows you to reshape based on functions of variables (based on the same underlying syntax as plyr):

  • better development practices like namespaces and tests.

  • the function melt now names the columns of its returned data frame Var1, Var2, ..., VarN instead of X1, X2, ..., XN.

  • the argument variable.name of melt replaces the old argument variable_name.

Initial benchmarking has shown melt to be up to 10x faster, pure reshaping cast up to 100x faster, and aggregating cast() up to 10x faster.

This work has been generously supported by BD (Becton Dickinson).

Installation

  • Get the released version from cran: install.packages("reshape2")
  • Get the dev version from github: devtools::install_github("hadley/reshape")

Functions in reshape2

Name Description
melt_check Check that input variables to melt are appropriate.
french_fries Sensory data from a french fries experiment.
melt.array Melt an array.
guess_value Guess name of value column
melt.data.frame Melt a data frame into form suitable for easy casting.
add_margins Add margins to a data frame.
melt.default Melt a vector. For vectors, makes a column of a data frame
colsplit Split a vector into multiple columns
cast Cast functions Cast a molten data frame into an array or data frame.
margins Figure out margining variables.
melt Convert an object into a molten data frame.
melt.list Melt a list by recursively melting each component.
parse_formula Parse casting formulae.
recast Recast: melt and cast in a single step
smiths Demo data describing the Smiths.
tips Tipping data
No Results!

Last month downloads

Details

URL https://github.com/hadley/reshape
BugReports https://github.com/hadley/reshape/issues
LinkingTo Rcpp
License MIT + file LICENSE
LazyData true
RoxygenNote 5.0.1.9000
NeedsCompilation yes
Packaged 2016-10-21 19:43:35 UTC; hadley
Repository CRAN
Date/Publication 2016-10-22 12:17:37

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/reshape2)](http://www.rdocumentation.org/packages/reshape2)