组或总和更多列
我想知道是否存在同一时间的“自动”方法“自动”。
library(dplyr)
abc <- iris %>%
group_by(Species) %>%
summarise(abc = sum(Petal.Width)) %>%
ungroup()
abc2 <- iris %>%
group_by(Species) %>%
summarise(abc = sum(Sepal.Width)) %>%
ungroup()
我可以为每列使用此代码,但是如果我需要做更多的列(在此数据集中,前四个),我该怎么办?而且我需要在同一数据集中,这是可能的吗?
I would like to know if exist a method "automatic" for calculted more column in the same time.
library(dplyr)
abc <- iris %>%
group_by(Species) %>%
summarise(abc = sum(Petal.Width)) %>%
ungroup()
abc2 <- iris %>%
group_by(Species) %>%
summarise(abc = sum(Sepal.Width)) %>%
ungroup()
I can use this code for each column but if i need to do more column (in this dataset the first four), how can I do? And I need in the same dataset, it is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作:
Try this: