In this post, I will show you how to download
FantasyPros fantasy football projections using R. The key advantage of FantasyPros is that it aggregates many sources of projections into its predictions, which increases prediction accuracy, as I discuss here.
The R Script for downloading fantasy football projections from FantasyPros is located at:
#Download fantasy football projections from FantasyPros.com
qb_fp <- readHTMLTable("http://www.fantasypros.com/nfl/projections/qb.php", stringsAsFactors = FALSE)$data
rb_fp <- readHTMLTable("http://www.fantasypros.com/nfl/projections/rb.php", stringsAsFactors = FALSE)$data
wr_fp <- readHTMLTable("http://www.fantasypros.com/nfl/projections/wr.php", stringsAsFactors = FALSE)$data
te_fp <- readHTMLTable("http://www.fantasypros.com/nfl/projections/te.php", stringsAsFactors = FALSE)$data
Here’s a density plot of the FantasyPros projections:
Tags: FantasyPros R
— 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.
i would like to check it out ….
First off: Thanks for introducing me to R, and thanks for showing your methodology instructions. I’ve been pulling all my data by hand and, needless to say, it’s been extremely time consuming.
I have a question for you about your League Settings.R file. I’m editing it for my own needs, but I noticed that you do not include a flex position. In my league, we have a RB/WR/TE flex slot. How would I add this to League Settings.R ?
I forgot to mention: What about D/ST? Thanks again!
Hey Gabriel, the “numQBstarters” variables in the League Settings.R file are for indicating how many minimum starters to retain for the optimization in the Draft Optimizer (http://apps.fantasyfootballanalytics.net/lineupoptimizer). You can specify flex positions in the tool by using the sliders. Mathematically, it’s setting the constraints so that you retain >= the minimum number of starters at each of the flex positions, yet staying within the total number of allowed starters. Does that make sense? I wrote scripts for downloading D/ST info here:
It wouldn’t be too difficult to modify the scraping and optimization scripts to include kickers and D/ST. My analysis showed that those positions should be last off the board (http://fantasyfootballanalytics.net/2013/07/expected-points-by-position-rank-in-fantasy-football.html), so my focus was on the other positions.
Hope that helps!
I’m very green to R…having a hard time understanding where your Functions.R and League Settings.R files are? Any help?
Check out Isaac’s Github: https://github.com/isaactpetersen/FantasyFootballAnalyticsR/tree/master/R%20Scripts
Does that help?
I’ve tried several times in the past to use R & GitHub but wasn’t “Getting It”, even after watching some videos on YouTube. I wanted to ask you if have or if you could make a YouTube Video on how to use both as it relates to Scraping Fantasy Football Analytic Stats? I’m sure it would help not only me but many of us who aren’t as bright when it comes to that sort of stuff as well!
Great suggestion! We’ll put this on our to-do list. In the meantime, you might check out this post: