Skip to content

Instantly share code, notes, and snippets.

@hornbeck
Forked from anonymous/gist:4448895
Last active December 10, 2015 14:38
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 hornbeck/4449093 to your computer and use it in GitHub Desktop.
Save hornbeck/4449093 to your computer and use it in GitHub Desktop.
setwd("R/")
setwd("NFL Play-by-Play Data 2002-2012/")
## read in the sweet, sweet NFL data
n <- read.csv("2012_nfl_pbp_data_reg_season.csv", header=TRUE)
## grab the no huddle plays
nh <- n[grep("Huddle", n$description),]
## table by offensive team and quarter
nh.df <- data.frame(table(nh$off, nh$qtr))[-1,]
colnames(nh.df) <- c("Team", "Quarter", "Number")
## plot bar chart, ordered by number of plays and colored by quarter
ggplot(nh.df, aes(x=reorder(Team, Number), y=Number, fill=Quarter)) + geom_bar() + labs(x="Team", y="Number", title="Number of No Huddle Plays in the NFL by Team by Quarter") + theme(axis.text.x = element_text(angle = 50, hjust = 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment