R 数据分组
我有一个数据表。第 1 栏案例编号、第 2 栏组和第 3 栏实际值。我想要在 R 中对这些数据进行分组汇总。因此,如果我可以执行三个组
m1=subset(m,group == 1)
m2=subset(m,group == 2)
m3=subset(m,group == 3)
,然后
summary(m1)
summary(m2)
summary(m3)
我正在寻找这些命令集的快捷方式,以便我可以对数据中的任意数量的组执行此操作。
I have a table of data. Col 1 Case Number, Col 2 Group and Col 3 actual values. I want group-wise summaries of this data in R. So if I have three groups I can do
m1=subset(m,group == 1)
m2=subset(m,group == 2)
m3=subset(m,group == 3)
and then
summary(m1)
summary(m2)
summary(m3)
I am looking for a shortcut to these sets of commands, so that I can do it for any number of groups in my data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
group
只有 3 个级别(不同/唯一值),您可以这样做Assuming that
group
has only 3 levels (distinct/unique values), you can do