Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

reshape2

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"
like image 938
Jack Frost Avatar asked Sep 18 '12 00:09

Jack Frost


2 Answers

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.

like image 108
Josh O'Brien Avatar answered Dec 15 '22 01:12

Josh O'Brien


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

like image 29
Dan Tarr Avatar answered Dec 15 '22 00:12

Dan Tarr