NFL Code on Github

January 2, 2013

(This article was first published on PirateGrunt » R, and kindly contributed to R-bloggers)

I’ve made some revisions and simplifications to the code to compile NFL data. It’s now all out on Github for anyone to play with in advance of the Superbowl. In the meantime, here’s a lovely picture comparing every team’s offense- as measured by total offensive yards- against their defenders.

Note the anemic Chicago offense.

p = ggplot(dfTeamVsTeam, aes(x = as.factor(ThisTeam), y = as.factor(Opponent), fill = ThisTeamTotalYards))
p = p + geom_tile() +  scale_fill_gradient(low="red", high="blue")
p = p + labs(title = "Total yardage", x = "Offense", y = "Defense")
p = p + theme(panel.grid.major = element_blank())


To leave a comment for the author, please follow the link and comment on his blog: PirateGrunt » R. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.