Built-in data

olympic_game

tokyo2020

medals

beijing2022

summer_games

winter_games

Format

An object of class tbl_df (inherits from tbl, data.frame) with 53 rows and 7 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 6900 rows and 7 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 1747 rows and 6 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 3785 rows and 6 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 43248 rows and 7 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 18628 rows and 7 columns.

Details

TODO

Examples

# slug for the recent 5 summer games
olympic_game %>% dplyr::filter(season == "Summer") %>% dplyr::pull(slug) %>% head(5)
#> [1] "tokyo-2020"   "rio-2016"     "london-2012"  "beijing-2008" "athens-2004" 


# Female single swimmer leaderboard
tokyo2020 %>%
 dplyr::filter(sport == "swimming",
              stringr::str_detect(event, "women"),
              !is.na(name),
              rank %in% c("G", "S", "B")) %>%
  dplyr::count(name, rank) %>%
  tidyr::pivot_wider(names_from = "rank", values_from = "n", values_fill = 0) %>%
  dplyr::select(name, G, S, B) %>%
  dplyr::arrange(desc(G), desc(S), desc(B))
#> # A tibble: 27 × 4
#>    name                    G     S     B
#>    <chr>               <int> <int> <int>
#>  1 Ariarne Titmus          2     1     0
#>  2 Katie Ledecky           2     1     0
#>  3 Emma Mckeon             2     0     1
#>  4 Kaylee Mckeown          2     0     0
#>  5 Yui Ohashi              2     0     0
#>  6 Tatjana Schoenmaker     1     1     0
#>  7 Yufei Zhang             1     1     0
#>  8 Lydia Jacoby            1     0     0
#>  9 Margaret Mac Neil       1     0     0
#> 10 Kylie Masse             0     2     0
#> # … with 17 more rows

# medal board from ...
unique(medals$game) %>% stringr::str_extract("\\d+") %>% min()
#> [1] "1908"

# Beijing winter olympic sports:
unique(beijing2022$sport)
#>  [1] "speed-skating"             "snowboard"                
#>  [3] "ski-jumping"               "skeleton"                 
#>  [5] "short-track-speed-skating" "nordic-combined"          
#>  [7] "luge"                      "ice-hockey"               
#>  [9] "freestyle-skiing"          "figure-skating"           
#> [11] "curling"                   "cross-country-skiing"     
#> [13] "bobsleigh"                 "biathlon"                 
#> [15] "alpine-skiing"            

# how many events are played in each summer/ winter game
summer_games %>% tidyr::nest(rank:result) %>% dplyr::count(game, sort = TRUE)
#> Warning: All elements of `...` must be named.
#> Did you want `data = rank:result`?
#> # A tibble: 6 × 2
#>   game             n
#>   <chr>        <int>
#> 1 tokyo-2020     339
#> 2 rio-2016       306
#> 3 london-2012    302
#> 4 beijing-2008   295
#> 5 athens-2004    292
#> 6 sydney-2000    291
winter_games %>% tidyr::nest(rank:result) %>% dplyr::count(game, sort = TRUE)
#> Warning: All elements of `...` must be named.
#> Did you want `data = rank:result`?
#> # A tibble: 6 × 2
#>   game                    n
#>   <chr>               <int>
#> 1 salt-lake-city-2002  2422
#> 2 beijing-2022          109
#> 3 pyeongchang-2018      102
#> 4 sochi-2014             93
#> 5 vancouver-2010         73
#> 6 turin-2006             61