Build an Engine Games Table from a cfbfastR Schedule
Source:R/games_from_schedule.R
cfb_games_from_schedule.RdMaps the schedule shape returned by cfbfastR::load_cfb_schedules() to
the games schema used by cfb_standings() and cfb_simulations().
cfbfastR is not required - any data frame with the expected columns works.
Value
A tibble in the engine games schema, ready for
cfb_standings() / cfb_simulations():
| Column | Type | Description |
season | integer | Season taken from the schedule. |
week | integer | Week number of the game. |
game_type | character | "REG", "CONF_CHAMP" (notes mention "championship"), or "POST" (season_type == "postseason"). |
home_team | character | Home team name. |
away_team | character | Away team name. |
result | numeric | Home margin (home minus away points); NA for unplayed games. |
neutral | integer | Neutral-site flag (0/1). |
Details
Game type mapping: season_type == "postseason" becomes "POST", games
whose notes contain "championship" (case-insensitive) become
"CONF_CHAMP", everything else "REG". This is a documented heuristic -
CFBD marks conference championship games as regular-season games with a
championship note.
See also
cfb_standings(), cfb_simulations(),
cfbfastR::load_cfb_schedules() from
cfbfastR,
the nflseedR original: https://nflseedr.com
Examples
schedule <- data.frame(
season = 2024, week = c(1, 1, 15, 16),
season_type = c("regular", "regular", "regular", "postseason"),
home_team = c("A1", "B1", "A1", "A1"),
away_team = c("A2", "B2", "A2", "B1"),
home_points = c(21, 24, 17, NA), away_points = c(14, 20, 14, NA),
neutral_site = c(FALSE, FALSE, TRUE, TRUE),
notes = c(NA, NA, "Alpha Championship Game", NA)
)
cfb_games_from_schedule(schedule)
#> # A tibble: 4 × 7
#> season week game_type home_team away_team result neutral
#> <dbl> <dbl> <chr> <chr> <chr> <dbl> <int>
#> 1 2024 1 REG A1 A2 7 0
#> 2 2024 1 REG B1 B2 4 0
#> 3 2024 15 CONF_CHAMP A1 A2 3 1
#> 4 2024 16 POST A1 B1 NA 1