• How To
    • Win Your DFS League
    • Win Your Auction Draft
    • Win Your Snake Draft
    • Download Projections
    • Scrape Projections
    • Calculate Projections for Your League
    • Examine Accuracy of Projections
    • Identify Sleepers
    • Save Custom Settings
    • Use the API
  • Strategy
    • Fantasy Football is Like Stock Picking
    • Use Projections, Not Rankings
  • Projections
    • Our Projections
    • Who has the Best Projections?
    • Draft the Best Starting Lineup
    • Projections are More Accurate than Rankings
    • Points by Position Rank
    • Players’ Risk Levels
    • Value Over Replacement
    • Bid-Up-To Value
    • Player Value Gap
    • Gold Mining
    • Weekly Variability
    • Are Subscription Sources More Accurate?
  • Statistics
    • How To Learn R
    • R is Better than Excel
    • Do Stats Help in Fantasy Football?
    • Download/Run Our Scripts
    • ffanalytics R Package
  • Apps
    • Auction Draft Optimizer
    • Snake Draft Optimizer
    • Weekly Lineup Optimizer
    • Rankings/Projections for Your League
    • API
    • Other Tools
      • Stock Analysis
    • Error Logging
  • Testimonials
  • About the Site
    • About
    • Authors
      • Isaac Petersen
    • FAQ
    • FFA Insider
    • Privacy Policy
    • Terms of Service
  • Donate

Fantasy Football Analytics

Download Fantasy Football Projections from ESPN.com using R

2
  • by Isaac Petersen
  • in How To · Projections · R
  • — 4 Mar, 2013

In this post, I will demonstrate how to download fantasy football projections from ESPN.com using R.  Having projections allows us to do many different analyses to determine our best possible fantasy team.  The projections on ESPN.com are currently from last year—they haven’t been updated yet for the upcoming season.  ESPN will update them closer to the start of the season.  In the meantime, last year’s projections can be helpful for determining their accuracy.

An important note of caution: the ESPN projections do not include fumbles.  If you know where ESPN includes projection data for fumbles, please let me know.

The R Script

The R Script for downloading fantasy football projections from ESPN.com is located at: https://github.com/FantasyFootballAnalytics/FantasyFootballAnalyticsR/blob/master/R%20Scripts/Projections/ESPN%20Projections.R

To scrape the ESPN projections from the ESPN.com website, we will use the readHTMLTable function from the XML package in R.

#Download fantasy football projections from ESPN.com
qb_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=0", stringsAsFactors = FALSE)$playertable_0
rb1_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=2", stringsAsFactors = FALSE)$playertable_0
rb2_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=2&startIndex=40", stringsAsFactors = FALSE)$playertable_0
rb3_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=2&startIndex=80", stringsAsFactors = FALSE)$playertable_0
wr1_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=4", stringsAsFactors = FALSE)$playertable_0
wr2_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=4&startIndex=40", stringsAsFactors = FALSE)$playertable_0
wr3_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=4&startIndex=80", stringsAsFactors = FALSE)$playertable_0
te_espn ("http://games.espn.go.com/ffl/tools/projections?&seasonTotals=true&seasonId=2012&slotCategoryId=6", stringsAsFactors = FALSE)$playertable_0

See the full R script to see how the data were processed to be more usable.

What do the data look like?

head(projections_espn)

Here are the first 6 lines of the data set:

name pos passYd passTD passINT rushYd rushTD recYd recTD pts
1 Aaron Rodgers  QB   4512     43       7    216      4     0     0 381
2 Tom Brady  QB   4924     40      13    167      2     0     0 354
3 Drew Brees  QB   4921     41      14     50      2     0     0 345
4 Matthew Stafford  QB   5012     41      17     60      1     0     0 338
5 Cam Newton  QB   3986     22      18    742      8     0     0 325
6 Arian Foster  RB      0      0       0   1459     12   730     2 296

Five out of the top 6 projected players from last year were quarterbacks.  As I will discuss in a future post, however, the number of points a player scores is not as important as how many points he scores relative to a typical replacement starter at his position.

Below is a density plot of ESPN’s projected points.  On the x- axis is the number of projected points for a given player.  On the y-axis is the frequency of players with that number of projected points.  The density plot shows a distribution similar to a zero-inflated Poisson or negative binomial distribution, where there are many players with 0 projected points, a peak around 50 points, and then a sharp decrease in the frequency until it tapers off above 250 points.

ggplot(projections_espn, aes(x=pts_espn)) + geom_density(fill="blue", alpha=.3) + xlab("Player's Projected Points") + ggtitle("Density Plot of ESPN Projected Points from 2012")

In my next post, I will show how to download CBS projections so that we can see which site provides more accurate projections.  If anyone has access to projections from other sources (e.g., Yahoo), please let me know.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

Share

Tags: ESPNR

— Isaac Petersen

My name is Isaac and I'm an assistant professor with a Ph.D. in Clinical Psychology. Why am I writing about fantasy football and data analysis? Because fantasy football involves the intersection of two things I love: sports and statistics. With this site, I hope to demonstrate the relevance of statistics for choosing the best team in fantasy football.

2 Comments

  1. Jeffrey Ross says:
    August 26, 2024 at 5:03 pm

    Sir,

    Even though I am not intelligent enought to follow the above and get the ESPN projections to download by themselves, I use https://www.fantasypros.com/nfl/projections/qb.php?week=draft which is an consensus of 5 projection sites (NFL, CBS, ESPN, numberFire and FFTODAY) and has an easy download button. Unfortunately, I wanted to only look at the ESPN projections and the site requires you to pick 2… strangely enough. Just realized this is from 2013 so this may be moot but thought I would share

    Reply
    • Isaac Petersen says:
      August 26, 2024 at 6:07 pm

      Thanks, Jeff! We provide a consensus of even more projection sites than that! The benefit of doing it in R (for those who are so inclined) is not having to do it “manually”, which can save time when performing analyses etc. Hope that helps!

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Previous story About the Author: Isaac Petersen
  • Next story Downloading CBS Fantasy Football Projections in R
  • Tabs

    • Most Popular
    • Recent Posts
    • The ffanalytics R Package for Fantasy Football Data AnalysisJune 18, 2016
    • 2015 Fantasy Football Projections using OpenCPUMay 28, 2015
    • Win Your Fantasy Football Auction Draft: Determine the Optimal Players to Draft with this AppJune 14, 2013
    • Win Your Fantasy Football Snake Draft with this AppSeptember 1, 2013
    • Post-Combine Mock: Team Needs and TargetsMarch 10, 2025
    • Fantasy Football Weekly Cheat Sheet: Week 18 (2024)January 3, 2025
    • Fantasy Football Weekly Cheat Sheet: Week 17 (2024)December 26, 2024
    • Fantasy Football Weekly Cheat Sheet: Week 16 (2024)December 18, 2024
  • FFA Insider

    Logo
  • Categories

    • About the Authors
    • Articles
    • Auction Drafts
    • Draft Optimizer
    • FFA Insider
    • Gold Mining
    • How To
    • In the Media
    • Luck
    • Package
    • Projections
    • R
    • Risk
    • Theory
    • Tools
    • Trade Strategy
    • Uncategorized
    • Weekly
  • Facebook

  • Twitter

  • Our Partners

    R-bloggers

  • Support us building things... Even a cup of coffee ($1.99) helps us stay awake!

  • Subscribe to the Fantasy Football Analytics mailing list (no spam).
    Loading

        © Fantasy Football Analytics

        %d