library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.8
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
rugby_data <- read_csv("http://teaching.statistics-is-awesome.org/wp-content/uploads/2015/11/rubgy_world_cup_20151.csv")
## Rows: 646 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): team, name, position, debut
## dbl (6): caps, years_since_debut, age, approx_age_debuted, height_cm, weight_kg
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
DebutYear <- as.numeric(format(as.Date(rugby_data$debut, "%d-%b-%y"), "%Y"))
Americas = c("Canada", "USA", "Argentina", "Uruguay")
Europe = c("England", "France", "Ireland", "Italy", "Romania", "Scotland", "Wales")
Asia = c("Georgia", "Japan")
Oceania = c("Australia", "Fiji", "New Zealand", "Samoa", "Tonga")
Africa = c("Namibia", "South Africa")
rugby_data <- rugby_data %>%
mutate(Continent = case_when(team %in% Americas ~"Americas",
team %in% Europe ~ "Europe",
team %in% Asia ~ "Asia",
team %in% Oceania ~ "Oceania",
team %in% Africa ~"Africa"))
rugby_data = rugby_data %>%
mutate(DebutYear) %>%
group_by(DebutYear, Continent) %>%
mutate(n = n())
ggplot(rugby_data, aes(DebutYear, n, col = Continent)) +
geom_line() +
geom_point()
## Warning: Removed 3 row(s) containing missing values (geom_path).
## Warning: Removed 3 rows containing missing values (geom_point).

sessionInfo()
## R version 4.2.0 (2022-04-22)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: EndeavourOS
##
## Matrix products: default
## BLAS: /usr/lib/libblas.so.3.10.1
## LAPACK: /usr/lib/liblapack.so.3.10.1
##
## locale:
## [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
## [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
## [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.8 purrr_0.3.4
## [5] readr_2.1.2 tidyr_1.2.0 tibble_3.1.7 ggplot2_3.3.6
## [9] tidyverse_1.3.1
##
## loaded via a namespace (and not attached):
## [1] lubridate_1.8.0 assertthat_0.2.1 digest_0.6.29 utf8_1.2.2
## [5] R6_2.5.1 cellranger_1.1.0 backports_1.4.1 reprex_2.0.1
## [9] evaluate_0.15 httr_1.4.3 highr_0.9 pillar_1.7.0
## [13] rlang_1.0.2 curl_4.3.2 readxl_1.4.0 rstudioapi_0.13
## [17] jquerylib_0.1.4 rmarkdown_2.13 labeling_0.4.2 bit_4.0.4
## [21] munsell_0.5.0 broom_0.8.0 compiler_4.2.0 modelr_0.1.8
## [25] xfun_0.30 pkgconfig_2.0.3 htmltools_0.5.2 tidyselect_1.1.2
## [29] fansi_1.0.3 crayon_1.5.1 tzdb_0.3.0 dbplyr_2.1.1
## [33] withr_2.5.0 grid_4.2.0 jsonlite_1.8.0 gtable_0.3.0
## [37] lifecycle_1.0.1 DBI_1.1.2 magrittr_2.0.3 scales_1.2.0
## [41] cli_3.3.0 stringi_1.7.6 vroom_1.5.7 farver_2.1.0
## [45] fs_1.5.2 xml2_1.3.3 bslib_0.3.1 ellipsis_0.3.2
## [49] generics_0.1.2 vctrs_0.4.1 tools_4.2.0 bit64_4.0.5
## [53] glue_1.6.2 hms_1.1.1 parallel_4.2.0 fastmap_1.1.0
## [57] yaml_2.3.5 colorspace_2.0-3 rvest_1.0.2 knitr_1.38
## [61] haven_2.5.0 sass_0.4.1