From f4b674c2c537134d79d2cce18e8ff34d59d46438 Mon Sep 17 00:00:00 2001 From: Ben Baldwin <1425357+guga31bb@users.noreply.github.com> Date: Fri, 19 Feb 2021 11:24:13 -0500 Subject: [PATCH] drive fix --- DESCRIPTION | 2 +- NEWS.md | 1 + R/helper_scrape_nfl.R | 15 --------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c60181fd..aba237d8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: nflfastR Title: Functions to Efficiently Access NFL Play by Play Data -Version: 4.0.0.9001 +Version: 4.0.0.9002 Authors@R: c(person(given = "Sebastian", family = "Carl", diff --git a/NEWS.md b/NEWS.md index 285be3e7..ff0c21a6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ * Added the function `calculate_player_stats()` that aggregates official passing, rushing, and receiving stats either at game level or overall * Added the new columns `td_player_name` and `td_player_id` to clearly identify the player who scored a touchdown (this is especially helpful for plays with multiple fumbles or laterals resulting in a touchdown) * Added the function `load_player_stats()` that loads weekly player stats from 1999 to the most recent season +* Fix bug in `drive` that was causing incorrect overtime win probabilities (#194) # nflfastR 4.0.0 diff --git a/R/helper_scrape_nfl.R b/R/helper_scrape_nfl.R index e1b5185f..74390da8 100644 --- a/R/helper_scrape_nfl.R +++ b/R/helper_scrape_nfl.R @@ -273,21 +273,6 @@ get_pbp_nfl <- function(id, dir = NULL, qs = FALSE) { .data$season <= 2015 & .data$yardline_side == 'JAX', 'JAC', .data$yardline_side ), - #if there's some random missing drive, fill in with previous drive - #this fixes a bug with plays appearing out of order after defensive TDs - drive = dplyr::if_else( - !is.na(dplyr::lag(.data$drive)) & !is.na(dplyr::lead(.data$drive)), - dplyr::lag(.data$drive), .data$drive - ), - #fix for drives being messed up in this game - drive = dplyr::case_when( - id == '2012_04_NO_GB' & .data$play_id == 1085 ~ 4, - id == '2012_16_BUF_MIA' & .data$play_id == 2571 ~ 15, - id == '2015_16_CHI_TB' & .data$play_id == 2182 ~ 14, - id == '2019_12_IND_HOU' & .data$play_id == 2579 ~ 12, - id == '2019_12_IND_HOU' & .data$play_id == 2544 ~ 11, - TRUE ~ .data$drive - ), time = dplyr::case_when( id == '2012_04_NO_GB' & .data$play_id == 1085 ~ '3:34', id == '2012_16_BUF_MIA' & .data$play_id == 2571 ~ '8:31',