R/apply_sharpe_mutations.R

Defines functions apply_sharpe_mutations

Documented in apply_sharpe_mutations

#' apply_sharp_mutations
#'
#' @param p Input dataframe
#'
#' @return
#' @export
#'
#' @examples
#' @import dplyr
apply_sharpe_mutations <- function(p)
{
  report("Applying Lee Sharpe mutations")
  p <- p %>%
    mutate(
      play_type=case_when(
        is.na(posteam) ~ "note",
        substr(desc,1,8) == "Timeout " ~ "note",
        desc == "*** play under review ***" ~ "note",
        TRUE ~ play_type
      ),
      special=ifelse(play_type %in%
                       c("extra_point","field_goal","kickoff","punt"),1,0))
}
jthomasmock/nflscrapRextra documentation built on Dec. 31, 2019, 12:55 a.m.