Compute NFL Division Rankings using Game Results

compute_division_ranks(
  games,
  teams = NULL,
  tiebreaker_depth = 3,
  .debug = FALSE,
  h2h = NULL
)

Arguments

games

A data frame containing real or simulated game scores. The following variables are required:

sim

A simulation ID. Normally 1 - n simulated seasons.

game_type

One of 'REG', 'WC', 'DIV', 'CON', 'SB' indicating if a game was a regular season game or one of the playoff rounds.

week

The week of the corresponding NFL season.

away_team

Team abbreviation of the away team (please see divisions for valid team abbreviations).

home_team

Team abbreviation of the home team (please see divisions for valid team abbreviations).

result

Equals home score - away score.

teams

This parameter is optional. If it is NULL the function will compute it internally, otherwise it has to be a data frame of all teams contained in the games data frame repeated for each simulation ID (sim). The following variables are required:

sim

A simulation ID. Normally 1 - n simulated seasons.

team

Team abbreviation of the team (please see divisions for valid team abbreviations).

conf

Conference abbreviation of the team (please see divisions for valid team abbreviations).

division

Division of the team (please see divisions for valid division names).

tiebreaker_depth

A single value equal to 1, 2, or 3. The default is 3. The value controls the depth of tiebreakers that shall be applied. The deepest currently implemented tiebreaker is strength of schedule. The following values are valid:

tiebreaker_depth = 1

Break all ties with a coinflip. Fastest variant.

tiebreaker_depth = 2

Apply head-to-head and division win percentage tiebreakers. Random if still tied.

tiebreaker_depth = 3

Apply all tiebreakers through strength of schedule. Random if still tied.

.debug

Either TRUE or FALSE. Controls whether additional messages are printed to the console showing what the tie-breaking algorithms are currently performing.

h2h

A data frame that is used for head-to-head tiebreakers across the tie-breaking functions. It is computed by the function compute_division_ranks.

Value

A list of two data frames:

standings

Division standings.

h2h

A data frame that is used for head-to-head tiebreakers across the tie-breaking functions.

See also

Examples

# \donttest{ # Change some options for better output old <- options(list(digits = 3, tibble.print_min = 64)) library(dplyr, warn.conflicts = FALSE) nflseedR::load_sharpe_games() %>% dplyr::filter(season %in% 2019:2020) %>% dplyr::select(sim = season, game_type, week, away_team, home_team, result) %>% nflseedR::compute_division_ranks() %>% purrr::pluck("standings")
#> 2021-04-17 18:35:32: Calculating team data
#> 2021-04-17 18:35:32: Calculating head to head
#> 2021-04-17 18:35:32: Calculating division rank #1
#> 2021-04-17 18:35:32: Calculating division rank #2
#> 2021-04-17 18:35:33: Calculating division rank #3
#> 2021-04-17 18:35:33: Calculating division rank #4
#> # A tibble: 64 x 14 #> sim conf division team games wins true_wins win_pct div_pct conf_pct #> <int> <chr> <chr> <chr> <int> <dbl> <int> <dbl> <dbl> <dbl> #> 1 2019 AFC AFC East BUF 16 10 10 0.625 0.5 0.583 #> 2 2019 AFC AFC East MIA 16 5 5 0.312 0.333 0.333 #> 3 2019 AFC AFC East NE 16 12 12 0.75 0.833 0.667 #> 4 2019 AFC AFC East NYJ 16 7 7 0.438 0.333 0.333 #> 5 2019 AFC AFC North BAL 16 14 14 0.875 0.833 0.833 #> 6 2019 AFC AFC North CIN 16 2 2 0.125 0.167 0.167 #> 7 2019 AFC AFC North CLE 16 6 6 0.375 0.5 0.5 #> 8 2019 AFC AFC North PIT 16 8 8 0.5 0.5 0.5 #> 9 2019 AFC AFC South HOU 16 10 10 0.625 0.667 0.667 #> 10 2019 AFC AFC South IND 16 7 7 0.438 0.5 0.417 #> 11 2019 AFC AFC South JAX 16 6 6 0.375 0.333 0.5 #> 12 2019 AFC AFC South TEN 16 9 9 0.562 0.5 0.583 #> 13 2019 AFC AFC West DEN 16 7 7 0.438 0.5 0.5 #> 14 2019 AFC AFC West KC 16 12 12 0.75 1 0.75 #> 15 2019 AFC AFC West LAC 16 5 5 0.312 0 0.25 #> 16 2019 AFC AFC West OAK 16 7 7 0.438 0.5 0.417 #> 17 2019 NFC NFC East DAL 16 8 8 0.5 0.833 0.583 #> 18 2019 NFC NFC East NYG 16 4 4 0.25 0.333 0.25 #> 19 2019 NFC NFC East PHI 16 9 9 0.562 0.833 0.583 #> 20 2019 NFC NFC East WAS 16 3 3 0.188 0 0.167 #> 21 2019 NFC NFC North CHI 16 8 8 0.5 0.667 0.583 #> 22 2019 NFC NFC North DET 16 3.5 3 0.219 0 0.208 #> 23 2019 NFC NFC North GB 16 13 13 0.812 1 0.833 #> 24 2019 NFC NFC North MIN 16 10 10 0.625 0.333 0.583 #> 25 2019 NFC NFC South ATL 16 7 7 0.438 0.667 0.5 #> 26 2019 NFC NFC South CAR 16 5 5 0.312 0.167 0.167 #> 27 2019 NFC NFC South NO 16 13 13 0.812 0.833 0.75 #> 28 2019 NFC NFC South TB 16 7 7 0.438 0.333 0.417 #> 29 2019 NFC NFC West ARI 16 5.5 5 0.344 0.167 0.292 #> 30 2019 NFC NFC West LA 16 9 9 0.562 0.5 0.583 #> 31 2019 NFC NFC West SEA 16 11 11 0.688 0.5 0.667 #> 32 2019 NFC NFC West SF 16 13 13 0.812 0.833 0.833 #> 33 2020 AFC AFC East BUF 16 13 13 0.812 1 0.833 #> 34 2020 AFC AFC East MIA 16 10 10 0.625 0.5 0.583 #> 35 2020 AFC AFC East NE 16 7 7 0.438 0.5 0.5 #> 36 2020 AFC AFC East NYJ 16 2 2 0.125 0 0.0833 #> 37 2020 AFC AFC North BAL 16 11 11 0.688 0.667 0.583 #> 38 2020 AFC AFC North CIN 16 4.5 4 0.281 0.167 0.333 #> 39 2020 AFC AFC North CLE 16 11 11 0.688 0.5 0.583 #> 40 2020 AFC AFC North PIT 16 12 12 0.75 0.667 0.75 #> 41 2020 AFC AFC South HOU 16 4 4 0.25 0.333 0.25 #> 42 2020 AFC AFC South IND 16 11 11 0.688 0.667 0.583 #> 43 2020 AFC AFC South JAX 16 1 1 0.0625 0.167 0.0833 #> 44 2020 AFC AFC South TEN 16 11 11 0.688 0.833 0.667 #> 45 2020 AFC AFC West DEN 16 5 5 0.312 0.167 0.333 #> 46 2020 AFC AFC West KC 16 14 14 0.875 0.667 0.833 #> 47 2020 AFC AFC West LAC 16 7 7 0.438 0.5 0.5 #> 48 2020 AFC AFC West LV 16 8 8 0.5 0.667 0.5 #> 49 2020 NFC NFC East DAL 16 6 6 0.375 0.333 0.417 #> 50 2020 NFC NFC East NYG 16 6 6 0.375 0.667 0.417 #> 51 2020 NFC NFC East PHI 16 4.5 4 0.281 0.333 0.333 #> 52 2020 NFC NFC East WAS 16 7 7 0.438 0.667 0.417 #> 53 2020 NFC NFC North CHI 16 8 8 0.5 0.333 0.5 #> 54 2020 NFC NFC North DET 16 5 5 0.312 0.167 0.333 #> 55 2020 NFC NFC North GB 16 13 13 0.812 0.833 0.833 #> 56 2020 NFC NFC North MIN 16 7 7 0.438 0.667 0.417 #> 57 2020 NFC NFC South ATL 16 4 4 0.25 0.167 0.167 #> 58 2020 NFC NFC South CAR 16 5 5 0.312 0.167 0.333 #> 59 2020 NFC NFC South NO 16 12 12 0.75 1 0.833 #> 60 2020 NFC NFC South TB 16 11 11 0.688 0.667 0.667 #> 61 2020 NFC NFC West ARI 16 8 8 0.5 0.333 0.5 #> 62 2020 NFC NFC West LA 16 10 10 0.625 0.5 0.75 #> 63 2020 NFC NFC West SEA 16 12 12 0.75 0.667 0.75 #> 64 2020 NFC NFC West SF 16 6 6 0.375 0.5 0.333 #> # … with 4 more variables: sov <dbl>, sos <dbl>, div_rank <dbl>, #> # max_reg_week <int>
# Restore old options options(old) # }