From ab0b289a62b93c32b0c362e57a87a97ef74944db Mon Sep 17 00:00:00 2001 From: mrcaseb Date: Mon, 22 Mar 2021 20:13:46 +0100 Subject: [PATCH] keep yardage string for 5 yard Face Mask penalties --- R/helper_add_nflscrapr_mutations.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/helper_add_nflscrapr_mutations.R b/R/helper_add_nflscrapr_mutations.R index a04dbeed..e2641649 100644 --- a/R/helper_add_nflscrapr_mutations.R +++ b/R/helper_add_nflscrapr_mutations.R @@ -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: