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

calculate_player_stats() no more counts lost fumbles on plays where… #431

Merged
merged 2 commits into from
Sep 15, 2023
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.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
Loading