3

It seems like melt will reshape your data frame with id columns and stacked measured variables after which a cast lets you perform aggregation. ddply, from the plyr package seems to be very similar..you give it a data frame, a couple of column variables for grouping, and an aggregation function and you get back a data frame...so how are they different and are there any good resources/references to share for learning these tools besides their documentation (which, especially for reshape, is a bit difficult to follow)

Thanks

Palace Chan
  • 8,845
  • 11
  • 41
  • 93

1 Answers1

3

One difference is that stats::reshape has a built-in way to handle "wide" data whereas reshape2 (cast/melt) does not. See this question for an example: Reshape in the middle

That said, stats::reshape has frustrating arguments and specializes in only one type of data transformation (albeit a common one).

plyr tends to be used in place of apply functions, whereas reshape2 tends to replace reshape. Even though the functionalities overlap, they each lend themselves to particular task.

Hadley Wickham, the author of the reshape2 and plyr packages, has a nice pdf on tidy data that's worth a read. He also has an article on plyr here: http://www.jstatsoft.org/v40/i01

Community
  • 1
  • 1
Ari B. Friedman
  • 71,271
  • 35
  • 175
  • 235