我试图检索数据框中存在的特定列中最重复的值.这是我的示例数据和代码如下.
data("Forbes2000", package = "HSAUR")
head(Forbes2000)
rank name country category sales profits assets marketvalue
1 1 Citigroup United States Banking 94.71 17.85 1264.03 255.30
2 2 General Electric United States Conglomerates 134.19 15.59 626.93 328.54
3 3 American Intl Group United States Insurance 76.66 6.46 647.66 194.87
4 4 ExxonMobil United States Oil & gas operations 222.88 20.96 166.99 277.02
5 5 BP United Kingdom Oil & gas operations 232.57 10.27 177.57 173.54
6 6 Bank of America United States …
Run Code Online (Sandbox Code Playgroud) 我想在data.frame中找到最常见的值组合.
这是一些示例数据:
dat <- data.frame(age=c(50,55,60,50,55),sex=c(1,1,1,0,1),bmi=c(20,25,30,20,25))
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我要找的结果是age = 55,sex = 1和bmi = 25的组合,因为这是列值的最常见组合.
我的真实数据有大约30000行和20列.在30000个观测值中找到这20个值的最常见组合的有效方法是什么?
非常感谢!