Skip to contents

All teams are ranked (if possible) by their contribution to the scoring variable.

Usage

get_ranking_by_one(data, variable, method = "normal")

Arguments

data

tibble of match information - it is assumed that each line corresponds to the score breakdown of one team in one event's match.

variable

numeric measurement.

method

character which model should be calculated? Either normal or loglinear.

Value

tibble of the ranked teams and the number of matches (n) that the ranking is based on.

Details

In order to model each team's contribution, a wide data set has to be constructed, with each team as a variable, and each row as one of the alliances in one match and their score. An alliance in a match consists of exactly three robots. This requirement is checked before modelling and if not fulfilled, results in a warning. A normal model is then fitted, or, if method = "loglinear" a log-linear model is fitted, if all values in the scoring variable are non-negative. The coefficients of this model can be interpreted as the average (log) contribution of that team to the score of a match. The OPR (offensive power rating) corresponds to a call to get_ranking_by with score as the variable.

Examples

# example code
# get all matches for one event:
matches <- get_records("event/2024cttd/matches")
# get the score breakdown for each of the teams in each match
match_details <- get_match_details(matches)

library(dplyr, quietly=TRUE)
# now get the contribution to the score:
match_details %>% filter(comp_level == "qm") %>% # get the qualifying matches
  get_ranking_by_one(score)
#> # A tibble: 42 × 3
#>    team_key `rating(score)`     n
#>    <chr>              <dbl> <int>
#>  1 frc3284             44.6     8
#>  2 frc5126             35.6     8
#>  3 frc1108             31.6     8
#>  4 frc1987             30.7     8
#>  5 frc3928             28.1     8
#>  6 frc1986             26.8     8
#>  7 frc2357             26.8     8
#>  8 frc6424             24.9     8
#>  9 frc1769             23.9     8
#> 10 frc5801             23.9     8
#> # ℹ 32 more rows
# These coefficients correspond to the OPR 

# team contribution to the score without counting the opponents' fouls:
match_details %>% filter(comp_level == "qm") %>% # get the qualifying matches
  get_ranking_by(score-foulPoints)
#> # A tibble: 42 × 3
#>    team_key     n `rating(score - foulPoints)`
#>    <chr>    <int>                        <dbl>
#>  1 frc1108      8                         32.4
#>  2 frc3284      8                         30.1
#>  3 frc1986      8                         28.7
#>  4 frc6424      8                         28.7
#>  5 frc1987      8                         27.5
#>  6 frc3928      8                         24.1
#>  7 frc2357      8                         23.1
#>  8 frc5126      8                         22.9
#>  9 frc5801      8                         21.0
#> 10 frc935       8                         20.3
#> # ℹ 32 more rows