R: Downloading a .csv from a website
<p>I'm trying to have R automatically download a .csv file from FanGraphs to a local directory.  To do this manually, I have to click on the "Export Data" link, whereby javascript is called for me to download the .csv file.  I've used Rvest before,  but I'm not sure how to complete this task.  The .csv file is very orderly once downloaded manually.  </p>

<p>Here is the link:</p>

<pre><code>url &lt;- "http://www.fangraphs.com/leaders.aspx?pos=all&amp;stats=bat&amp;lg=all&amp;qual=y&amp;type=8&amp;season=2016&amp;month=0&amp;season1=2016&amp;ind=0"
</code></pre>

<p>Here is the link to the download:</p>

<pre><code>href="javascript:__doPostBack('LeaderBoard1$cmdCSV','')"
</code></pre>

<p>I'm stumped and would appreciate any help!  Thank you in advance.</p>