NFL Code on Github
[This article was first published on PirateGrunt » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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.
https://github.com/PirateGrunt/NFL
library(ggplot2) 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()) print(p)
To leave a comment for the author, please follow the link and comment on their blog: PirateGrunt » R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.