Skip to content

Commit

Permalink
Merge pull request #431 from nflverse/player-stats-lost-fumbles
Browse files Browse the repository at this point in the history
`calculate_player_stats()` no more counts lost fumbles on plays where…
  • Loading branch information
mrcaseb authored Sep 15, 2023
2 parents 354674e + 7c747bc commit db0214b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
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.5.1.9012
Version: 4.5.1.9013
Authors@R:
c(person(given = "Sebastian",
family = "Carl",
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions R/aggregate_game_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
) %>%
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit db0214b

Please sign in to comment.