Skip to content

Instantly share code, notes, and snippets.

@friscojosh
Last active September 20, 2018 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save friscojosh/d50a7314d55c930fe8c28ef564b71870 to your computer and use it in GitHub Desktop.
Save friscojosh/d50a7314d55c930fe8c28ef564b71870 to your computer and use it in GitHub Desktop.
Analysis of holding calls by play type
###################################################
#### Analysis of holding calls by play type
#### Data from nfldb by burntsushi
#### https://github.com/BurntSushi/nfldb
#### Josh Hermsmeyer 9/20/18
###################################################
library(tidyverse)
### Load the play descriptions and play types
plays <- read_csv("data/all_plays.csv")
### Filter out all non penalty plays for now, find Offensive Holding penalties,
### then tag plays by pattern matching strings by play type: punt, scramble, pass.
### Remove holding calls on punts.
penalties <- plays %>%
filter(note == "PENALTY") %>%
mutate(holding = ifelse(str_detect(description, "Offensive Holding"), 1, 0)) %>%
filter(holding == 1) %>%
mutate(punt = ifelse(str_detect(description, "punts"), 1, 0)) %>%
filter(punt == 0) %>%
mutate(pass = ifelse(str_detect(description, "pass"), 1, 0)) %>%
mutate(scramble = ifelse(str_detect(description, "scrambles"), 1, 0))
### Assume all other plays are runs. A quick check appears to confirm this.
run_penalties <- penalties %>%
filter(pass == 0,
scramble == 0)
### Holding calls on passing plays
pass_penalties <- penalties %>%
filter(pass == 1)
### Holding calls on scrambles
scramble_penalties <- penalties %>%
filter(scramble == 1)
### Add the counts together and calculate percentage of holding penalties on runs
count(run_penalties) / (count(run_penalties) + count(pass_penalties) + count(scramble_penalties))
### 59.6 %
### According to https://www.pro-football-reference.com/years/NFL/index.htm
### league average runpass split since 2009 is ~ 45% run 55% pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment