Downloading CBS Fantasy Football Projections in R
2In this post, I will show how to download CBS fantasy football projections using R.
The R Script
The R Script for downloading fantasy football projections from CBS is located at: https://github.com/FantasyFootballAnalytics/FantasyFootballAnalyticsR/blob/master/R%20Scripts/Projections/CBS%20Projections.R
Here are lines of code to download the CBS projections from CBSsports.com:
#Download fantasy football projections from cbssports.com qb_cbs ("http://fantasynews.cbssports.com/fantasyfootball/stats/weeklyprojections/QB/season", stringsAsFactors = FALSE)[7]$'NULL' rb1_cbs ("http://fantasynews.cbssports.com/fantasyfootball/stats/weeklyprojections/RB/season", stringsAsFactors = FALSE)[7]$'NULL' rb2_cbs ("http://fantasynews.cbssports.com/fantasyfootball/stats/weeklyprojections/RB/season?&start_row=51", stringsAsFactors = FALSE)[7]$'NULL' wr1_cbs ("http://fantasynews.cbssports.com/fantasyfootball/stats/weeklyprojections/WR/season", stringsAsFactors = FALSE)[7]$'NULL' wr2_cbs ("http://fantasynews.cbssports.com/fantasyfootball/stats/weeklyprojections/WR/season?&start_row=51", stringsAsFactors = FALSE)[7]$'NULL' te_cbs ("http://fantasynews.cbssports.com/fantasyfootball/stats/weeklyprojections/TE/season", stringsAsFactors = FALSE)[7]$'NULL'
Here’s a density plot of the CBS projections:
ggplot(projections_cbs, aes(x=pts_cbs)) + geom_density(fill="red", alpha=.3) + xlab("Player's Projected Points") + ggtitle("Density Plot of CBS Projected Points from 2012")
In my next post, I will show how to download NFL.com fantasy football projections using R.
Share
Hey Isaac. I am completely novice to R and programming. I have wanted to create my own fantasy football software so that I can play with different aspects of game play. I have a couple of computer science buddies to build the software but I am wondering about where to pull the data from. This post shows how to pull the data for projections. What I will need is real time data during games to pull data from what is happening. Do you have any idea where CBS, ESPN, etc. get their data? So Julio catches a pass and everyone’s league stats are automatically updated. Are they all pulling from a common source? Thanks so much.
A lot of the bigger companies use Stats LLC or a similar provider but that type of data is out of our scope at this point.