A summary statistic can be realized among multiple groups.
# Multiple groups
data % > %
group_by(yearID, teamID) % > %
summarise(mean_games = mean(G)) % > %
arrange(desc(teamID, yearID))
Code Explanation
- group_by(yearID, teamID): Group by year and team
- summarise(mean_games = mean(G)): Summarize the number of game player
- arrange(desc(teamID, yearID)): Sort the data by team and year