Skip to contents

Given a teams-matches data frame (returned by uss_make_teams_matches()), return return a data frame on wins, losses, points, etc.:

  • cumulative, over the course of each season: uss_make_seasons_cumulative()

  • final result for each season: uss_make_seasons_final()

Usage

uss_make_seasons_cumulative(
  data_teams_matches,
  fn_points_per_win = uss_points_per_win
)

uss_make_seasons_final(
  data_teams_matches,
  fn_points_per_win = uss_points_per_win
)

Arguments

data_teams_matches

data frame created using uss_make_teams_matches()

fn_points_per_win

function with vectorized arguments country, season, that returns a integer indicating points-per-win. A default function is provided, uss_points_per_win(), which includes the countries in uss_countries(). You can also provide a purrr-style anonymous function, e.g. ~3.

Value

tibble with columns country, tier, season, team, date, matches, wins, draws, losses, points, goals_for, goals_against.

Examples

italy <- uss_get_matches("italy") |> uss_make_teams_matches()
uss_make_seasons_cumulative(italy)
#> # A tibble: 50,808 × 12
#> # Groups:   country, tier, season, team [1,516]
#>    country tier  season team     date       matches  wins draws losses points
#>    <chr>   <fct>  <int> <chr>    <date>       <int> <int> <int>  <int>  <int>
#>  1 Italy   1       1929 AC Milan 1929-10-06       1     1     0      0      2
#>  2 Italy   1       1929 AC Milan 1929-10-13       2     2     0      0      4
#>  3 Italy   1       1929 AC Milan 1929-10-20       3     2     0      1      4
#>  4 Italy   1       1929 AC Milan 1929-10-27       4     3     0      1      6
#>  5 Italy   1       1929 AC Milan 1929-11-03       5     3     1      1      7
#>  6 Italy   1       1929 AC Milan 1929-11-10       6     3     1      2      7
#>  7 Italy   1       1929 AC Milan 1929-11-17       7     3     1      3      7
#>  8 Italy   1       1929 AC Milan 1929-11-24       8     4     1      3      9
#>  9 Italy   1       1929 AC Milan 1929-12-08       9     4     1      4      9
#> 10 Italy   1       1929 AC Milan 1929-12-15      10     5     1      4     11
#> # … with 50,798 more rows, and 2 more variables: goals_for <int>,
#> #   goals_against <int>
uss_make_seasons_final(italy)
#> # A tibble: 1,516 × 12
#> # Groups:   country, tier, season [85]
#>    country tier  season team        date       matches  wins draws losses points
#>    <chr>   <fct>  <int> <chr>       <date>       <int> <int> <int>  <int>  <int>
#>  1 Italy   1       1929 AC Milan    1930-07-06      34    11    10     13     32
#>  2 Italy   1       1929 AS Roma     1930-07-06      34    15     6     13     36
#>  3 Italy   1       1929 Bologna FC  1930-07-06      34    14     8     12     36
#>  4 Italy   1       1929 Brescia Ca… 1930-07-06      34    13     7     14     33
#>  5 Italy   1       1929 Calcio Pad… 1930-07-06      34    11     4     19     26
#>  6 Italy   1       1929 Genova 189… 1930-07-06      34    20     8      6     48
#>  7 Italy   1       1929 Inter       1930-07-06      34    22     6      6     50
#>  8 Italy   1       1929 Juventus    1930-07-06      34    19     7      8     45
#>  9 Italy   1       1929 Lazio Roma  1930-07-06      34    10     8     16     28
#> 10 Italy   1       1929 Modena FC   1930-07-06      34    11     8     15     30
#> # … with 1,506 more rows, and 2 more variables: goals_for <int>,
#> #   goals_against <int>