Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top