From 5f48cff549c40fb8e0c333bcfc4b41f700d1f574 Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Fri, 15 Sep 2023 20:59:41 +0200 Subject: [PATCH 1/2] `calculate_player_stats()` no more counts lost fumbles on plays where a player fumbles, a team mate recovers and then loses a fumble to the defense. --- R/aggregate_game_stats.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/aggregate_game_stats.R b/R/aggregate_game_stats.R index 53f40442..80d76ef7 100644 --- a/R/aggregate_game_stats.R +++ b/R/aggregate_game_stats.R @@ -200,7 +200,7 @@ calculate_player_stats <- function(pbp, weekly = FALSE) { attempts = sum(.data$complete_pass == 1 | .data$incomplete_pass == 1 | .data$interception == 1), completions = sum(.data$complete_pass == 1), sack_fumbles = sum(.data$fumble == 1 & .data$fumbled_1_player_id == .data$passer_player_id), - sack_fumbles_lost = sum(.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$passer_player_id), + sack_fumbles_lost = sum(.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$passer_player_id & .data$fumble_recovery_1_team != .data$posteam), passing_air_yards = sum(.data$air_yards, na.rm = TRUE), sacks = sum(.data$sack), sack_yards = -1*sum(.data$yards_gained * .data$sack), @@ -258,7 +258,7 @@ calculate_player_stats <- function(pbp, weekly = FALSE) { tds = sum(.data$td_player_id == .data$rusher_player_id, na.rm = TRUE), carries = dplyr::n(), rushing_fumbles = sum(.data$fumble == 1 & .data$fumbled_1_player_id == .data$rusher_player_id & is.na(.data$lateral_rusher_player_id)), - rushing_fumbles_lost = sum(.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$rusher_player_id & is.na(.data$lateral_rusher_player_id)), + rushing_fumbles_lost = sum(.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$rusher_player_id & is.na(.data$lateral_rusher_player_id) & .data$fumble_recovery_1_team != .data$posteam), rushing_first_downs = sum(.data$first_down_rush & is.na(.data$lateral_rusher_player_id)), rushing_epa = sum(.data$epa, na.rm = TRUE) ) %>% @@ -360,7 +360,7 @@ calculate_player_stats <- function(pbp, weekly = FALSE) { targets = dplyr::n(), tds = sum(.data$td_player_id == .data$receiver_player_id, na.rm = TRUE), receiving_fumbles = sum(.data$fumble == 1 & .data$fumbled_1_player_id == .data$receiver_player_id & is.na(.data$lateral_receiver_player_id)), - receiving_fumbles_lost = sum(.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$receiver_player_id & is.na(.data$lateral_receiver_player_id)), + receiving_fumbles_lost = sum(.data$fumble_lost == 1 & .data$fumbled_1_player_id == .data$receiver_player_id & is.na(.data$lateral_receiver_player_id) & .data$fumble_recovery_1_team != .data$posteam), receiving_air_yards = sum(.data$air_yards, na.rm = TRUE), receiving_yards_after_catch = sum(.data$yards_after_catch, na.rm = TRUE), receiving_first_downs = sum(.data$first_down_pass & is.na(.data$lateral_receiver_player_id)), From 7c747bc7c280ee7613b7779a11fc497a774d5a6e Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Fri, 15 Sep 2023 21:00:50 +0200 Subject: [PATCH 2/2] version and news bullet --- DESCRIPTION | 2 +- NEWS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6dbcaca7..99a1630e 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.5.1.9012 +Version: 4.5.1.9013 Authors@R: c(person(given = "Sebastian", family = "Carl", diff --git a/NEWS.md b/NEWS.md index 6e6c8452..729ee676 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,7 @@ - Decode player IDs in 2023 pbp. (#425) - Drop the pseudo plays TV Timeout and Two-Minute Warning. (#426) - Fix posteam on kickoffs and PATs following a defensive TD in 2023+ pbp. (#427) +- `calculate_player_stats()` no more counts lost fumbles on plays where a player fumbles, a team mate recovers and then loses a fumble to the defense. (#431) # nflfastR 4.5.1