Skip to contents

For teams_matches tibbles, it can be convenient to see the result as a structure, rather than using only goals_for and goals_against.

Usage

uss_result(goals_for = integer(), goals_against = integer())

Arguments

goals_for

integer-ish number of goals for a team in a match.

goals_against

integer-ish number of goals against a team in a match.

Value

An S3 object with class ussie_result.

Details

This function is vectorized over goals_for and goals_against; they must have the same length.

Examples

uss_result(3, 2)
#> <ussie_result[1]>
#> [1] W 3-2
uss_get_matches("italy") |>
  uss_make_teams_matches() |>
  dplyr::mutate(
    result = uss_result(goals_for, goals_against),
    .after = opponent
  )
#> # A tibble: 50,808 × 10
#>    country tier  season team     date       at_home opponent    result goals_for
#>    <chr>   <fct>  <int> <chr>    <date>     <lgl>   <chr>       <uss_>     <int>
#>  1 Italy   1       1929 AC Milan 1929-10-06 TRUE    Brescia Ca…  W 4-1         4
#>  2 Italy   1       1929 AC Milan 1929-10-13 TRUE    Modena FC    W 1-0         1
#>  3 Italy   1       1929 AC Milan 1929-10-20 FALSE   SSC Napoli   L 1-2         1
#>  4 Italy   1       1929 AC Milan 1929-10-27 TRUE    AS Roma      W 3-1         3
#>  5 Italy   1       1929 AC Milan 1929-11-03 FALSE   Bologna FC   D 1-1         1
#>  6 Italy   1       1929 AC Milan 1929-11-10 TRUE    Inter        L 1-2         1
#>  7 Italy   1       1929 AC Milan 1929-11-17 FALSE   US Livorno   L 1-4         1
#>  8 Italy   1       1929 AC Milan 1929-11-24 TRUE    Lazio Roma   W 2-1         2
#>  9 Italy   1       1929 AC Milan 1929-12-08 FALSE   Juventus     L 1-3         1
#> 10 Italy   1       1929 AC Milan 1929-12-15 TRUE    US Cremone…  W 5-2         5
#> # … with 50,798 more rows, and 1 more variable: goals_against <int>