使用.groups参数覆盖
我不断获得“ summarize()
已按'new_brand'分组输出。您可以使用 .groups
参数。“我不确定我是否会遇到此错误,因为我
superbowl %>% group_by(new_brand, superbowl) %>% summarize(mean(superbowl$volume, superbowl$pos_prop, superbowl$neg_prop), sd(superbowl$volume, superbowl$pos_prop, superbowl$neg_prop)) %>% filter(superbowl, superbowl == "0")
在运行rlang :: last_error()
code时 创建了pos_prop和neg_prop有效,我不确定如何正确运行代码。
I keep getting "summarise()
has grouped output by 'new_brand'. You can override using
the .groups
argument." I'm not sure if I'm getting this error because I created columns pos_prop and neg_prop
superbowl %>% group_by(new_brand, superbowl) %>% summarize(mean(superbowl$volume, superbowl$pos_prop, superbowl$neg_prop), sd(superbowl$volume, superbowl$pos_prop, superbowl$neg_prop)) %>% filter(superbowl, superbowl == "0")
When I run rlang::last_error()
The code works, I'm not sure how to make the code run properly. Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用
总结
和此类错误。尝试以下尝试:在您的代码上注释:
dplyr
-pipe,带有superbowl%>%
,几乎从不$ 在dplyr动词中(非常罕见的例外);我还删除了superbowl
的引用,group_by
和filter
,因为尚不清楚您是否要参考原始帧符号同样...如果您有superbowl $ superbowl
,那么它们仍然可能是合适的;跨(..)
如上所述,要么命名计算,例如,summarize(polumion_mu = sean = polums_mu = pos_mu = mean(pos_prop),...)
> ;和平均值(卷,pos_prop,neg_prop)
(有或没有superbowl $
)是一个错误:在这种情况下,呼叫有效均值(卷,trim = pos_prop,na.rm = neg_prop)
,应该产生错误。一个 可以将其适应为平均值(c(卷,pos_prop,neg_prop))
如果您真的想将三列的数据汇总到一个数字中,但是我认为这是可能是意外的过度聚集。用真实数据证明这一点:
You're using
summarize
and such incorrectly. Try this:Notes on your code:
dplyr
-pipe withsuperbowl %>%
, almost never usesuperbowl$
in the dplyr verbs (very rare exceptions); I also removed references tosuperbowl
in bothgroup_by
andfilter
, since it is not clear if you're trying to refer to the original frame symbol again ... if you havesuperbowl$superbowl
, then they may still be appropriate;across(..)
as above or name the calculations, e.g.,summarize(volume_mu = mean(volume), pos_mu = mean(pos_prop), ...)
; andmean(volume, pos_prop, neg_prop)
(with or without thesuperbowl$
) is an error: in this case, the call is effectivelymean(volume, trim=pos_prop, na.rm=neg_prop)
, which should be producing errors. One could adapt this to bemean(c(volume, pos_prop, neg_prop))
if you really want to aggregate three columns' data into a single number, but I thought that might be unintended over-aggregation.Demonstration of this with real data: