Skip to contents

Maps 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.

Usage

cfb_games_from_schedule(schedule)

Arguments

schedule

A data frame with at least season, week, season_type, home_team, away_team. Optional columns used when present: home_points/away_points (to compute result), neutral_site, and notes (games whose notes mention "championship" are classified as "CONF_CHAMP").

Value

A tibble in the engine games schema, ready for cfb_standings() / cfb_simulations():

ColumnTypeDescription
seasonintegerSeason taken from the schedule.
weekintegerWeek number of the game.
game_typecharacter"REG", "CONF_CHAMP" (notes mention "championship"), or "POST" (season_type == "postseason").
home_teamcharacterHome team name.
away_teamcharacterAway team name.
resultnumericHome margin (home minus away points); NA for unplayed games.
neutralintegerNeutral-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.

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