Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final step of scramble fixes #489

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: nflfastR
Title: Functions to Efficiently Access NFL Play by Play Data
Version: 4.6.1.9017
Version: 4.6.1.9018
Authors@R:
c(person(given = "Sebastian",
family = "Carl",
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- Fixed a bug in `fixed_drive` and `fixed_drive_result` where the second weather delay in `2023_13_ARI_PIT` wasn't identified correctly. (#461)
- `punter_player_id`, and `punter_player_name` are filled for blocked punt attempts. (#463)
- Fixed an issue affecting scores of 2022 games involving a return touchdown (#466)
- Added identification of scrambles from 1999 through 2004 with thank to Aaron Schatz (#468)
- Added identification of scrambles from 1999 through 2004 with thank to Aaron Schatz (#468, #489)
- nflfastR tried to fix bugs in the underlying pbp data of JAX home games prior to the 2016 season. An update of the raw pbp data resolved those bugs so nflfastR needs to remove the hard coded adjustments. This means that nflfastR <= v4.6.1 will return incorrect pbp data for all Jacksonville home games prior to the 2016 season! (#478)
- Fixed a problem where `clean_pbp()` returned `pass = 1` in actual rush plays in very rare cases. (#479)
- Removed extra lines for injury timeouts that were breaking `fixed_drive` (#482)
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
Binary file not shown.
25 changes: 24 additions & 1 deletion data-raw/build_scramble_fix.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ s2 <- readxl::read_xlsx("data-raw/Scrambles 1999-2004 UPDATE for NFLfastR.xlsx",
select(
season = year, week, qtr, away_team = away, home_team = home, posteam = offense, down, ydstogo = togo, date_time = time, yards_gained = yards
)
# s3 is a correction. the plays are in s3 should be rushes and therefore excluded from scramble_fix
# see #475
s3 <- readxl::read_xlsx("data-raw/Scrambles.1999-2003.FURTHER.UPDATE.for.NFLfastR.xlsx", sheet = 1) |>
as_tibble() |>
janitor::clean_names() |>
select(
season = year, week, qtr, away_team = away, home_team = home, posteam = offense, down, ydstogo = togo, date_time = time, yards_gained = yards
) %>%
mutate(
time = paste0(
formatC(lubridate::hour(date_time), width = 2, flag = "0"),
":",
formatC(lubridate::minute(date_time), width = 2, flag = "0")
)
) %>%
select(-date_time) %>%
mutate_at(vars(home_team, away_team, posteam), nflfastR:::team_name_fn) %>%
dplyr::left_join(
pbp,
by = c("week", "away_team", "home_team", "posteam", "qtr", "down", "ydstogo", "time", "season")
) %>%
mutate(no_scramble_id = paste0(game_id, "_", play_id))

dat <- bind_rows(
s2,
Expand All @@ -56,7 +78,8 @@ d <- dat %>%
by = c("week", "away_team", "home_team", "posteam", "qtr", "down", "ydstogo", "time", "season")
) %>%
mutate(scramble_id = paste0(game_id, "_", play_id)) %>%
filter(scramble_id != "2005_09_CIN_BAL_1725")
filter(scramble_id != "2005_09_CIN_BAL_1725") %>%
filter(!scramble_id %in% s3$no_scramble_id)

# number non-matched by season
nrow(d)
Expand Down
Binary file modified data-raw/scramble_fix.rds
Binary file not shown.
Loading