The function n() returns the number of observations in a current group. A closed function to n() is n_distinct(), which count the number of unique values.
In the next example, you add up the total of players a team recruited during the all periods.
# distinct values
data % > %
group_by(teamID) % > %
summarise(number_player = n_distinct(playerID)) % > %
- group_by(teamID): Group by year and team
- summarise(number_player = n_distinct(playerID)): Count the distinct number of players by team
- arrange(desc(number_player)): Sort the data by the number of player