<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/calculating-college-basketball-rankings-using-functional-programming-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://dpmartin42.github.io/posts/r/college-basketball-rankings"> Wicked Good Data</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>March Madness is officially upon us as College Basketball teams across the US try to get a few more signature wins on their resume during conference tournaments before <a rel="nofollow" href="https://www.ncaa.com/news/basketball-men/march-madness-selection-sunday-dates-schedule" target="_blank">Selection Sunday</a>. With only 30 or so games in a given season and around 350 teams in Division I, being able to measure the relative strength of teams who have not played one another becomes an important challenge.</p>
<p>Unsurprisingly, there are literally hundreds of different ranking systems for College Basketball and other sports, some created by large news organizations and others by passionate fans. The focus here today is to describe two popular methods, the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Rating_percentage_index" target="_blank">Rating Percentage Index (RPI)</a> and the <a rel="nofollow" href="https://www.pro-football-reference.com/blog/index4837.html?p=37" target="_blank">Simple Rating System (SRS)</a>, that you can easily calculate and track yourself using functional programming in R. Then, in future posts to be released throughout the tournament season over the next few weeks, I will be able to use the rating systems described here to answer some interesting questions about tournament teams in the past and what is happening in 2018.</p>
<p>For this, we will need the following R packages, and a small dataset outlining an example season.</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>readr</span><span>)</span><span> </span><span># for reading in data</span><span>
</span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span> </span><span># for data cleaning</span><span>
</span><span>library</span><span>(</span><span>purrr</span><span>)</span><span> </span><span># for functional programming</span><span>
</span><span>library</span><span>(</span><span>forcats</span><span>)</span><span> </span><span># for recoding factors</span><span>
</span><span>library</span><span>(</span><span>limSolve</span><span>)</span><span> </span><span># for solving linear equations</span><span>
</span><span># Read in data example</span><span>
</span><span>ex_data</span><span> </span><span>&lt;-</span><span> </span><span>read_csv</span><span>(</span><span>&quot;../data/SmallExampleResults.csv&quot;</span><span>)</span><span>
</span><span>ex_data</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>## # A tibble: 6 x 5
##   WTeamID WScore   LTeamID LScore  WLoc
##     </code></pre></div></div>