dplyr:“n()中的错误:函数不应该直接调用” [英] dplyr: "Error in n(): function should not be called directly"

查看:360
本文介绍了dplyr:“n()中的错误:函数不应该直接调用”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重现dplyr包中的一个示例,但是这个错误信息。我期待看到一个新的列n产生与每个组合的频率。有人可以告诉我我失踪了吗?我三重检查包装是否加载。感谢您的帮助,一如既往。

 库(dplyr)
#总结剥离单层分组
by_vs_am< - group_by(mtcars,vs,am)

by_vs< - summarize(by_vs_am,n = n())

# ):这个函数不应该被直接调用


解决方案

您在同一会话中加载了 dplyr plyr dplyr 不是 plyr ddply 不是 dplyr 包中的函数。



dplyr plyr 的功能总结 / 总结



查看 conflicts()以查看蒙版对象。


I am attempting to reproduce one of the examples in the dplyr package but this error message. I am expecting to see a new column n produced with the frequency of each combination. Can someone tell me what I am missing? I triple checked that the package is loaded. Thanks for the help, as always.

 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

解决方案

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.

这篇关于dplyr:“n()中的错误:函数不应该直接调用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆