【发布时间】:2019-07-27 06:10:21
【问题描述】:
我有一个这样的数据集
>head(grocery)
milk bread juice honey eggs beef ... (140 more variables)
1 4 3 1 4 2
2 5 4 2 4 3
1 2 6 0 7 0
0 1 5 3 3 1
4 10 2 1 5 8
我想选择总和值最大的 3 列,显示顺序、列名和总和值,并将它们按降序排列。像这样:
1 eggs 23
2 bread 22
3 juice 20
我该怎么做?
非常感谢您的帮助!
【问题讨论】:
-
我建议使用
gather-grouby-summarise-top_n方法。