dplyr: "Error in n(): function should not be called directly"
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.
As mentioned by the previous answer, you may have a conflict between plyr and dplyr. You can to run this command to unload the plyr package.
detach("package:plyr", unload=TRUE)
Then you can continue as expected.
library(dplyr)
...
summarise(n = n())
To avoid confusions with masking functions, it is clear to use the "package::function" specification, like example below:
delay <- dplyr::summarise(by_tailnum,
count = n(),
dist = mean(distance, na.rm = TRUE),
delay = mean(arr_delay, na.rm = TRUE))