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

问题描述

我正在尝试重现 dplyr 包中的示例之一,但收到此错误消息.我期待看到每个组合的频率产生一个新的列 n.我错过了什么?我三次检查了包是否已加载.

 库(dplyr)# 总结剥离单层分组by_vs_am 

n() 中的错误:不应直接调用此函数

解决方案

我想你在同一个会话中加载了 dplyrplyr.dplyr 不是 plyr.ddply 不是 dplyr 包中的函数.

dplyrplyr 都有函数 summarise/summarize.

查看 conflicts() 的结果以查看被屏蔽的对象.

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())
解决方案

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() 中的错误:不应直接调用函数";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:27
查看更多