Skip to content

Commit

Permalink
More safety info (#252)
Browse files Browse the repository at this point in the history
* add safety vars to tidy play stats row

* fill safety vars

* add safety vars to variable selector

* add docs for safety vars

* don't really need safety team

* Increment version number

* update NEWS

* remove safety team, it's unnecessary
  • Loading branch information
mrcaseb authored Jul 8, 2021
1 parent 76525b0 commit 9e18261
Show file tree
Hide file tree
Showing 10 changed files with 18 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.1.0.9005
Version: 4.1.0.9006
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 @@ -13,6 +13,7 @@
* Fix for `fixed_drive` where it wasn't incrementing when there was a muffed punt followed by timeout (#244)
* Fix for `fixed_drive` where it wasn't incrementing following an interception with the intercepting player then losing a fumble (#247)
* Fix for more issues with missing play info in 2018_01_ATL_PHI (#246)
* Added the variables `safety_player_name` and `safety_player_id` to the play-by-play data (#252)

# nflfastR 4.1.0

Expand Down
2 changes: 2 additions & 0 deletions R/helper_tidy_play_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,8 @@ sum_play_stats <- function(play_Id, stats) {
row$blocked_player_name <- play_stats$player.displayName[index]
} else if (stat_id == 89) {
row$safety <- 1
row$safety_player_id <- play_stats$player.esbId[index]
row$safety_player_name <- play_stats$player.displayName[index]
} else if (stat_id == 91) {
row$fumble <- 1
row$forced_fumble_player_1_player_id <-
Expand Down
6 changes: 4 additions & 2 deletions R/helper_variable_selector.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
################################################################################
# Author: Ben Baldwin
# Author: Ben Baldwin, Sebastian Carl
# Purpose: Build the final output of the pbp functions
# Code Style Guide: styler::tidyverse_style()
################################################################################
Expand Down Expand Up @@ -114,7 +114,9 @@ nflscrapr_cols <-
"defensive_two_point_attempt",
"defensive_two_point_conv",
"defensive_extra_point_attempt",
"defensive_extra_point_conv"
"defensive_extra_point_conv",
#new in nflfastR > v4.1
"safety_player_name", "safety_player_id"
)


Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
2 changes: 2 additions & 0 deletions R/top-level_scraper.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@
#' \item{defensive_two_point_conv}{Binary indicator whether or not the defense successfully scored on the two point conversion.}
#' \item{defensive_extra_point_attempt}{Binary indicator whether or not the defense was able to have an attempt on an extra point attempt, this results following a blocked attempt that the defense recovers the ball.}
#' \item{defensive_extra_point_conv}{Binary indicator whether or not the defense successfully scored on an extra point attempt.}
#' \item{safety_player_name}{String name for the player who scored a safety.}
#' \item{safety_player_id}{Unique identifier for the player who scored a safety.}
#' \item{season}{4 digit number indicating to which season the game belongs to.}
#' \item{cp}{Numeric value indicating the probability for a complete pass based on comparable game situations.}
#' \item{cpoe}{For a single pass play this is 1 - cp when the pass was completed or 0 - cp when the pass was incomplete. Analyzed for a whole game or season an indicator for the passer how much over or under expectation his completion percentage was.}
Expand Down
5 changes: 4 additions & 1 deletion data-raw/tidy_play_stats_row.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ pbp_stat_columns <-
"half_sack_1_player_id",
"half_sack_1_player_name",
"half_sack_2_player_id",
"half_sack_2_player_name"
"half_sack_2_player_name",
# new in nflfastR > v4.1
"safety_player_name",
"safety_player_id"
)

indicator_stats <- c(
Expand Down
2 changes: 2 additions & 0 deletions data-raw/variable_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@
#' \item{defensive_two_point_conv}{Binary indicator whether or not the defense successfully scored on the two point conversion.}
#' \item{defensive_extra_point_attempt}{Binary indicator whether or not the defense was able to have an attempt on an extra point attempt, this results following a blocked attempt that the defense recovers the ball.}
#' \item{defensive_extra_point_conv}{Binary indicator whether or not the defense successfully scored on an extra point attempt.}
#' \item{safety_player_name}{String name for the player who scored a safety.}
#' \item{safety_player_id}{Unique identifier for the player who scored a safety.}
#' \item{season}{4 digit number indicating to which season the game belongs to.}
#' \item{cp}{Numeric value indicating the probability for a complete pass based on comparable game situations.}
#' \item{cpoe}{For a single pass play this is 1 - cp when the pass was completed or 0 - cp when the pass was incomplete. Analyzed for a whole game or season an indicator for the passer how much over or under expectation his completion percentage was.}
Expand Down
Binary file modified data/field_descriptions.rda
Binary file not shown.
2 changes: 2 additions & 0 deletions man/fast_scraper.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e18261

Please sign in to comment.