<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/the-ffanalytics-r-package-for-fantasy-football-data-analysis/"></div></div><div><a data-url="http://www.r-bloggers.com/the-ffanalytics-r-package-for-fantasy-football-data-analysis/" data-counturl="http://www.r-bloggers.com/the-ffanalytics-r-package-for-fantasy-football-data-analysis/" data-count="horizontal" data-text="The ffanalytics R Package for Fantasy Football Data Analysis" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://fantasyfootballanalytics.net/2016/06/ffanalytics-r-package-fantasy-football-data-analysis.html"> R – Fantasy Football Analytics</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<h1>Introduction</h1>
<p>We are continuously looking to provide users ways to replicate our analyses and improve their performance in fantasy football. To that aim, we are introducing the ffanalytics R package that includes a streamlined version of the scripts used to scrape projections from multiple sources and calculate projected points using the wisdom of the crowd.</p>
<h1>What Software You Need</h1>
<ul>
<li><a target="_blank" href="http://cran.r-project.org/">R</a> (for running the scripts)</li>
<li><a target="_blank" href="http://www.rstudio.com/ide/download/">RStudio</a> (best text editor for viewing, editing, and running R scripts)</li>
</ul>
</div>
<div>
<h1>Installation</h1>
<p>The package is available through <a target="_blank" href="https://github.com/dadrivr/FantasyFootballAnalyticsR/tree/master/R%20Package">our GitHub repository</a>, and installation requires that you have already installed the <code>devtools</code> package. You can install the <code>devtools</code> package in R/RStudio via:</p>
<pre><code>install.packages(&quot;devtools&quot;)</code></pre>
<p>You can then install the ffanalytics R package via:</p>
<pre>devtools::install_github(repo = &quot;dadrivr/FantasyFootballAnalyticsR&quot;,  subdir = &quot;R Package/ffanalytics&quot;)</pre>
<p>There is also a <a target="_blank" href="https://github.com/dadrivr/FantasyFootballAnalyticsR/tree/master/R%20Package">tarball</a> available in the GitHub repository that you can download and install with <a target="_blank" href="https://stat.ethz.ch/R-manual/R-devel/library/utils/html/install.packages.html"><code>install.packages()</code></a>. After the package is installed you can then load the package via:</p>
<pre>library(&quot;ffanalytics&quot;)</pre>
<div>
<h1>Package manual</h1>
<p>The package includes a reference manual in standard package format. You can also find this in the help pane in RStudio. The full PDF version of the manual is <a target="_blank" href="https://github.com/dadrivr/FantasyFootballAnalyticsR/blob/master/R%20Package/ffanalytics/ffanalytics.pdf">here</a>.</p>
</div>
</div>
<div>
<h1>Addins</h1>
<p>The <code>ffanalytics</code> package includes <a target="_blank" href="http://rstudio.github.io/rstudioaddins/">RStudio addins</a> to help you easily scrape and calculate projections. To use the addins, you will need to run RStudio (v0.99.878 or later). The first addin <code>Run Scrape</code> will just scrape projections while <code>Run Projections</code> will scrape projection and calculate projected points. The addins will construct code and return them to the console in RStudio to be executed. Because the <code>Run Projections</code> addin contains functionality of the <code>Run Scrape</code> addin, we will just focus on the projections addin here.</p>
<div>
<h2>Run Projections addin</h2>
<p>The <code>Run Projections</code> addin consists of three tabs that you will need to review before executing the function to scrape and calculate projections.</p>
<div>
<h3>1. Scrape Settings</h3>
<p>When you start the projections addin, you should see the tab where you can select which season, week, sources, and positions you want to scrape. Select the season and week you want to scrape (<code>week=0</code> for seasonal projections). Then select the analysts and positions you want to scrape. The function has the ability to include subscription based sources, but you will need to either download subscription projections separately or provide a user name and password for those sites. Note that historical data scrapes are nearly impossible to do as sites usually don’t store their historical projections.</p>
<p><img sizes="(max-width: 824px) 100vw, 824px" srcset="http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Run-Data-Scrape.png?w=824 824w, http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Run-Data-Scrape.png?resize=255%2C300 255w, http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Run-Data-Scrape.png?resize=768%2C904 768w, http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Run-Data-Scrape.png?resize=720%2C848 720w" alt="Run Data Scrape" class="wp-image-3512" src="http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Run-Data-Scrape.png?resize=720%2C848" data-recalc-dims="1"></p>
<p> </p>
</div>
<div>
<h3>2. Scoring Settings</h3>
<p>Review and set the scoring settings for the calculations on the scoring settings tab. There is a panel for each position with the names of the variables to score. These settings are similar to the ones in our <a target="_blank" href="http://apps.fantasyfootballanalytics.net/projections">Projections tool</a>. Use the scoring setting that match your league’s.</p>
<p><img sizes="(max-width: 824px) 100vw, 824px" srcset="http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Scoring-Settings.png?w=824 824w, http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Scoring-Settings.png?resize=256%2C300 256w, http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Scoring-Settings.png?resize=768%2C901 768w, http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Scoring-Settings.png?resize=720%2C845 720w" alt="Scoring Settings" class="wp-image-3513" src="http://i2.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Scoring-Settings.png?resize=720%2C845" data-recalc-dims="1"></p>
</div>
<div>
<h3>3. Calculation Settings</h3>
<p>On the calculations tab, select which average you want to use for aggregating the sources and calculating projected points. Then, select which sources of ADP values to use. It also allows you to select which MFL drafts types to use when getting the ADP data.  Tiers are calculated using <a target="_blank" href="https://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d">effect size</a> thresholds based on <a target="_blank" href="https://en.wikiversity.org/wiki/Cohen%27s_d">Cohen’s d</a>.  Smaller d values result in more tiers (fewer players per tier).</p>
<p><img sizes="(max-width: 823px) 100vw, 823px" srcset="http://i0.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Calculation-Settings.png?w=823 823w, http://i0.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Calculation-Settings.png?resize=255%2C300 255w, http://i0.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Calculation-Settings.png?resize=768%2C905 768w, http://i0.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Calculation-Settings.png?resize=720%2C849 720w" alt="Calculation Settings" class="wp-image-3514" src="http://i0.wp.com/fantasyfootballanalytics.net/wp-content/uploads/2016/06/Calculation-Settings.png?resize=720%2C849" data-recalc-dims="1"></p>
</div>
</div>
</div>
<div>
<h1>Execute R code</h1>
<p>You can also execute the code to run directly from R or RStudio. If you want to run a data scrape then you can execute, e.g.:</p>
<pre><code>runScrape(week = 0, season = 2016, analysts = c(-1, 5, 7, 18, 27), positions = c(&quot;QB&quot;, &quot;RB&quot;, &quot;WR&quot;, &quot;TE&quot;, &quot;K&quot;, &quot;DST&quot;))</code></pre>
<p>This scrapes seasonal projections for the 2016 season for 5 different analysts for the Non-IDP positions. Refer to the <code>analysts</code> table in the package to identify the analysts you want to use.</p>
<p>If you want to calculate projections from R or RStudio, you will need the output from the <code>runScrape()</code> function. Then you can execute:</p>
<pre><code>getProjections(scrapeData, avgMethod = &quot;average&quot;, leagueScoring = userScoring, teams = 12, format = &quot;standard&quot;, mflMocks = -1, mflLeagues = -1, adpSources = c(&quot;CBS&quot;, &quot;ESPN&quot;, &quot;FFC&quot;, &quot;MFL&quot;, &quot;NFL&quot;))</code></pre>
<p>where <code>scrapeData</code> is the output from the <code>runScrape()</code> function and <code>userScoring</code> is your defined scoring rules. See <code>scoringRules</code> in the package for how to define scoring rules.</p>
<h1>Troubleshooting</h1>
<p>If you run into errors or issues, feel free to let us know in the comments or to open a GitHub issue on <a target="_blank" href="https://github.com/dadrivr/FantasyFootballAnalyticsR">our GitHub repo</a>.  If you are able to find and fix an issue, please share the fix with the community (for more info how to share your scripts with the community, see <a target="_blank" href="http://fantasyfootballanalytics.net/2014/10/download-run-r-scripts.html">here</a>).</p>
<h1>Downloading Our R Scripts</h1>
<p>In addition to the ffanalytics R Package, we also have R scripts that accompany posts on the site.  To download and run our R scripts, see <a target="_blank" href="http://fantasyfootballanalytics.net/2014/10/download-run-r-scripts.html">here</a>.  If you’d rather calculate projections using our webapps without the R package, see <a target="_blank" href="http://fantasyfootballanalytics.net/2014/06/custom-rankings-and-projections-for-your-league.html">here</a>.  We encourage people to use and improve our scripts, and to share them with the community so everyone benefits.  For info on how to share your scripts with the community, see <a target="_blank" href="http://fantasyfootballanalytics.net/2014/10/download-run-r-scripts.html">here</a>.</p>
</div>
<p>The post <a target="_blank" rel="nofollow" href="http://fantasyfootballanalytics.net/2016/06/ffanalytics-r-package-fantasy-football-data-analysis.html">The ffanalytics R Package for Fantasy Football Data Analysis</a> appeared first on <a target="_blank" rel="nofollow" href="http://fantasyfootballanalytics.net/">Fantasy Football Analytics</a>.</p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/the-ffanalytics-r-package-for-fantasy-football-data-analysis/"></div></div><div><a data-url="http://www.r-bloggers.com/the-ffanalytics-r-package-for-fantasy-football-data-analysis/" data-counturl="http://www.r-bloggers.com/the-ffanalytics-r-package-for-fantasy-football-data-analysis/" data-count="vertical" data-text="The ffanalytics R Package for Fantasy Football Data Analysis" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://fantasyfootballanalytics.net/2016/06/ffanalytics-r-package-fantasy-football-data-analysis.html"> R – Fantasy Football Analytics</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/wwpzxEOs2Hw"></a></div>