Created
January 4, 2013 00:41
-
-
Save anonymous/4448895 to your computer and use it in GitHub Desktop.
plot no huddle plays by team by quarter in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(x, 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