Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dplyr: "Error in n(): function should not be called directly"

I am attempting to reproduce one of the examples in the dplyr package but am getting this error message. I am expecting to see a new column n produced with the frequency of each combination. What am I missing? I triple checked that the package is loaded.

 library(dplyr) # summarise peels off a single layer of grouping by_vs_am <- group_by(mtcars, vs, am)  by_vs <- summarise(by_vs_am, n = n()) 

Error in n() : This function should not be called directly

like image 333
Michael Bellhouse Avatar asked Apr 02 '14 03:04

Michael Bellhouse


1 Answers

I presume you have dplyr and plyr loaded in the same session. dplyr is not plyr. ddply is not a function in the dplyr package.

Both dplyr and plyr have the functions summarise/summarize.

Look at the results of conflicts() to see masked objects.

like image 56
mnel Avatar answered Sep 21 '22 21:09

mnel