0

This paper that was published for reshape package (Wickham 2007) gave this example:

library(reshape2)
ffm <- melt(french_fries, id = 1:4, na.rm = TRUE)

dcast(ffm, variable ~ ., c(min, max))

Similarly, this doesn't work in reshape2 but appears to work in Wickham 2007

dcast(ffm, variable ~ ., summary)

However the cast function is giving an error. How can I get function to work?

luciano
  • 13,158
  • 36
  • 90
  • 130
  • 2
    The [paper](http://www.jstatsoft.org/v21/i12/paper) is using `reshape` rather than `reshape2` and, more importantly, it uses the `cast` function rather than the `dcast` function. – Justin Aug 28 '13 at 21:11

1 Answers1

3

The paper is for the reshape package, not the reshape2 package. You have also not reproduced the example as it was written. It should be:

library("reshape") # not explicit in the paper, but implied since it is for the reshape pacakge
ffm <- melt(french_fries, id = 1:4, na.rm = TRUE)
cast(ffm, treatment ~ rep, c(min, max))

Note that the function call is cast, not dcast. That change was one of the major changes between the two packages. Another was the dropping of multiple aggregation at the same time as reshaping as this was considered to be better handled by the plyr package. If you use the reshape package (which is still available from CRAN), the examples work.

Brian Diggs
  • 57,757
  • 13
  • 166
  • 188
  • Do you know why ability to use functions like min(), max() and summary() were dropped in reshape2? – luciano Aug 29 '13 at 07:44
  • 3
    @luciano you can still use those functions, but only one at a time. If you're doing multiple aggregation, you're probably better off using plyr. – hadley Aug 29 '13 at 12:47