18
votes

In following Hadley Wickham's "Practical tools for exploring data and models" examples in section 2.4, Casting molten data I'm getting Error: could not find function "cast". I have the reshape2 package installed and loaded.

> cast(msmithsm, time + subject ~ variable)
Error: could not find function "cast"
2
Could you post your sessionInfo()?Luciano Selzer
> sessioninfo() Error: could not find function "sessioninfo"Jack Frost
Not that you need to run it here, but that has to be sessionInfo() (not sessioninfo()).Josh O'Brien

2 Answers

24
votes

In reshape2, cast() has been replaced by two functions: acast() and dcast().

From ?cast, in package reshape2:

Description:

Use ‘acast’ or ‘dcast’ depending on whether you want vector/matrix/array output or data frame output.

2
votes

Had related issue (Error: could not find function "dcast"). I had old library, library(plyr), so just added to code...

install.packages("reshape2") # may already be installed
library(reshape2)

Then dcast worked again