The dataset is available on Kaggle: https://www.kaggle.com/heesoo37/120-years-of-olympic-history-athletes-and-results/
I need to use dplyr to create an object which contains, for each
combination of Sex
and Season
, the number of different sports in the data set.
I first group the dataset with sex, season and sport, summarized them, which gives me a table with too many rows, with column Sex, Season and Sport. This is not right. Then I used n() in the summarize function, which returned me the same result, only with one more column: number of people
final_group<- group_by(dataset, Sex, Season)
final_group_1 <- summarise(final_group)
then i tried:
final_group<- group_by(dataset, Sex, Season)
final_group_1 <- summarise(final_group, n())
both did not return what I want.
I only want 4 rows with the sums of all sports played in the summer or winter by each gender, like the example shown below:
Sex Season Num_sports
Male summer ( all sports played by males in the summer )
Male winter ( all sports played by males in the winter )
Female summer ( all sports played by females in the summer )
Female winter ( all sports played by females in the winter )