0

I was running code from a month ago with the tidyr package's spread() function, and it now throws the error below. Does the code need to be changed, or the package updated?

Error in get("as_data_frame.matrix", asNamespace("tibble"), mode = "function") :
object 'as_data_frame.matrix' of mode 'function' was not found

I've tried checking that the dataframe is formatted correctly, spelling out the inputs, and with an oversimplified example. Still gives me the same error.

#make a new dataframe
x<-c("A","A","B","B")
y<-c("USA","EU","USA","EU")
z<-c(1,2,3,4)
test1<-cbind.data.frame(x,y,z)

#confirm it is a dataframe
str(test1)
test1$y

#try out spread() function
test2<-spread(data=test1,key=y,value=z)

outputs this error instead of a re-arranged table

Error in get("as_data_frame.matrix", asNamespace("tibble"), mode = "function") :
object 'as_data_frame.matrix' of mode 'function' was not found

Is anyone else seeing this happen? How did you solve it?

1 Answer 1

1

Okay, that was trivial. Updated the tidyr package through the R Studio dialog and it works again. Sorry.

> test2<-spread(data=test1,key=y,value=z)
> test2
  x EU USA
1 A  2   1
2 B  4   3
2
  • Hi Zuzana, do you remember which versions of tidyr you had before and after ? I'm running into the exact same issue, yet updating tidyr doesnt seem to resove it.
    – MrFronk
    Dec 31, 2019 at 10:31
  • running 0.6.0 at the moment
    – MrFronk
    Dec 31, 2019 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.