library(ussie)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, unionThe goal of ussie is to help you work with European Football League data. It uses data from the engsoccerdata package.
We can create a matches tibble using raw data from engsoccerdata:
matches_italy <- uss_make_matches(engsoccerdata::italy, "Italy")
glimpse(matches_italy)
#> Rows: 25,404
#> Columns: 8
#> $ country <chr> "Italy", "Italy", "Italy", "Italy", "Italy", "Italy", "I…
#> $ tier <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ season <int> 1934, 1934, 1934, 1934, 1934, 1934, 1934, 1934, 1934, 19…
#> $ date <date> 1934-09-30, 1934-09-30, 1934-09-30, 1934-09-30, 1934-09…
#> $ home <chr> "Lazio Roma", "Torino FC", "Sampierdarenese", "SSC Napol…
#> $ visitor <chr> "US Livorno", "Unione Triestina", "Bologna FC", "US Ales…
#> $ goals_home <int> 6, 3, 2, 0, 4, 0, 3, 1, 1, 1, 2, 4, 2, 2, 3, 2, 2, 2, 0,…
#> $ goals_visitor <int> 1, 1, 1, 1, 1, 2, 0, 2, 1, 1, 1, 0, 2, 1, 1, 0, 1, 1, 1,…Get country data
the function uss_get_matches() can get the data for a country.
uss_get_matches('england') |>
glimpse()
#> Rows: 192,004
#> Columns: 8
#> $ country <chr> "England", "England", "England", "England", "England", "…
#> $ tier <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ season <int> 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 1888, 18…
#> $ date <date> 1888-12-15, 1889-01-19, 1889-03-23, 1888-12-01, 1888-10…
#> $ home <chr> "Accrington F.C.", "Accrington F.C.", "Accrington F.C.",…
#> $ visitor <chr> "Aston Villa", "Blackburn Rovers", "Bolton Wanderers", "…
#> $ goals_home <int> 1, 0, 2, 5, 6, 3, 1, 0, 2, 2, 4, 4, 6, 6, 4, 4, 2, 9, 0,…
#> $ goals_visitor <int> 1, 2, 3, 1, 2, 1, 2, 0, 0, 1, 4, 3, 1, 2, 2, 2, 1, 1, 2,…We can add filtering condition:
uss_get_matches("italy", season == 2000) |>
dplyr::glimpse()
#> Rows: 306
#> Columns: 8
#> $ country <chr> "Italy", "Italy", "Italy", "Italy", "Italy", "Italy", "I…
#> $ tier <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ season <int> 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 20…
#> $ date <date> 2000-10-01, 2000-10-01, 2000-10-01, 2000-10-01, 2000-10…
#> $ home <chr> "Udinese Calcio", "AS Roma", "AC Perugia", "Reggina Calc…
#> $ visitor <chr> "Brescia Calcio", "Bologna FC", "US Lecce", "Inter", "Ju…
#> $ goals_home <int> 4, 2, 1, 2, 1, 2, 2, 1, 2, 3, 1, 1, 0, 2, 2, 0, 2, 3, 3,…
#> $ goals_visitor <int> 2, 0, 1, 1, 2, 0, 2, 1, 2, 1, 2, 1, 4, 0, 1, 0, 1, 0, 1,…