could not find function "cast" despite reshape2 installed and loaded

Jack Frost picture Jack Frost · Sep 18, 2012 · Viewed 12.1k times · Source

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"

Answer

Josh O'Brien picture Josh O'Brien · Sep 18, 2012

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.