title: Could someone explain what "compiling" in R is, and why it would speed up this code?
body: <p>I am working on some R code written by a previous student. The code is extremely computationally intensive, and for that reason he appears to have gone to great lengths to minimise the time it took in anyway possible.</p>
  
  <p>One example is the following section:</p>
  
  <pre><code># Now lets compile these functions, for a modest speed boost.
  Sa &lt;- cmpfun(Sa)
  Sm &lt;- cmpfun(Sm)
  sa &lt;- cmpfun(sa)
  sm &lt;- cmpfun(sm)
  h &lt;- cmpfun(h)
  li &lt;- cmpfun(lli)
  ll &lt;- cmpfun(ll)
  </code></pre>
  
  <p>He appears to have used the compiler package to do this.</p>
  
  <p>I have never heard of compiling in R, and I am interested in what it does and why it would help speed up the code. I am having trouble finding material that would explain it for a novice like me.</p>