Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以让我更具体一点......我有一个数据集
足球队-球员
巴萨-梅西
巴萨-哈维
-RM-CR
-RM - 佩佩
-RM -HIQUAIN 等(只是一个例子,不是数据集)
作为列!!!
我想要这个问题的答案: “我如何根据他们使用的球员数量找到前 5 名球队” *球队可以多次使用球员,因此不可能找到因子水平 *所以如果巴萨使用了 15 名球员并且Rm 使用了 14,然后 BARCA 是第一个......
library(dplyr) df %>% group_by(SOCCERTEAM) %>% summarize(rank = n_distinct(PLAYERS)) %>% top_n(5, wt = rank)