So let me be a little more specific..... i have a dataset that has
SOCCERTEAM -PLAYERS
BARCA - MESSI
BARCA - XAVI
-RM - CR
-RM - CR
-RM - PEPE
-RM -HIQUAIN etc(just an example not dataset)
as columns!!!
I want the answer to this question : " How can i find the top 5 teams according to how many players they used" *teams can use players more than once so finding the factor levels are not a possibility *so if barca used 15 players and Rm used 14 then BARCA is first.....
library(dplyr)
df %>%
group_by(SOCCERTEAM) %>%
summarize(rank = n_distinct(PLAYERS)) %>%
top_n(5, wt = rank)