Skip to content

Commit

Permalink
Merge pull request #500 from nflverse/stats-receiving-air-yards
Browse files Browse the repository at this point in the history
Fix `receiving_air_yards`
  • Loading branch information
mrcaseb authored Dec 3, 2024
2 parents 70cc022 + ba00e9e commit 1741e87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 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: 5.0.0
Version: 5.0.0.9000
Authors@R:
c(person(given = "Sebastian",
family = "Carl",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# nflfastR (development version)

- Fixed a bug where `calculate_stats()` incorrectly counted `receiving_air_yards`. (#500)

# nflfastR 5.0.0

## Major Changes
Expand Down
2 changes: 1 addition & 1 deletion R/calculate_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ calculate_stats <- function(seasons = nflreadr::most_recent_season(),
# cannot appear more than once per play.
# If this ever changes, we can use pbp instead.
receiving_air_yards = if (.env$stat_type == "player"){
sum( (stat_id %in% 21:22) * dplyr::first(.data$team_play_air_yards))
sum( (stat_id == 115) * .data$team_play_air_yards )
} else .data$passing_air_yards,
receiving_yards_after_catch = sum((stat_id == 113) * yards),
receiving_first_downs = sum((stat_id %in% 21:22) & has_id(4, team_stats)),
Expand Down

0 comments on commit 1741e87

Please sign in to comment.