Skip to content

Commit

Permalink
keep yardage string for 5 yard Face Mask penalties
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaseb committed Mar 22, 2021
1 parent d564c06 commit ab0b289
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/helper_add_nflscrapr_mutations.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ add_nflscrapr_mutations <- function(pbp) {
.data$penalty == 1,
.data$play_description %>%
stringr::str_extract("(?<=PENALTY on .{1,50}, ).{1,50}(?=, [0-9]{1,2} yard)") %>%
# For some reason Face Mask penalties include the string (15 Yards)
# Seb thought it's ok to drop that with the next two lines
stringr::str_remove("\\(.+\\)") %>%
# Face Mask penalties include the yardage as string (either 5 Yards or 15 Yards)
# We remove the 15 Yards part and just keep the additional info if it's a
# 5 yard Face Mask penalty
stringr::str_remove("\\([0-9]{2}+ Yards\\)") %>%
stringr::str_squish(), NA_character_
),
# Make plays marked with down == 0 as NA:
Expand Down

0 comments on commit ab0b289

Please sign in to comment.