Skip to content

Commit

Permalink
Add NFL game outcomes dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
ryurko committed Jul 8, 2024
1 parent 1698e9d commit adf2ae5
Show file tree
Hide file tree
Showing 4 changed files with 1,737 additions and 1 deletion.
25 changes: 25 additions & 0 deletions _prep/nfl-games/get-mahomes-era-nfl-games.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# PURPOSE: Get a table of the NFL during the Patrick Mahomes era, 2018 to now

library(tidyverse)
library(nflreadr)

# Load the data for the recent season -------------------------------------

# Considering the Mahomes era to start when he was named the starter
nfl_games <- load_schedules(seasons = 2018:2023)

# Set-up the data to be in an easy format ---------------------------------

nfl_games <- nfl_games |>
dplyr::select(season, game_id, game_type, week, home_team, away_team,
home_score, away_score) |>
mutate(game_outcome = case_when(
home_score > away_score ~ 1,
home_score == away_score ~ 0.5,
.default = 0),
score_diff = home_score - away_score)

# Save the data -----------------------------------------------------------

write_csv(nfl_games,
"data/nfl_mahomes_era_games.csv")
Loading

0 comments on commit adf2ae5

Please sign in to comment.