title: na.locf and inverse.rle in Rcpp
body: <p>I wanted to check if there is any pre-existing trick for <code>na.locf</code> (from <code>zoo</code> package), <code>rle</code> and <code>inverse.rle</code> in <code>RCpp</code>?</p>
  
  <p>I wrote a loop to implement, e.g. I did the implementation of <code>na.locf(x, na.rm=FALSE, fromLast=FALSE)</code> as follows:</p>
  
  <pre><code>#include &lt;Rcpp.h&gt;
  using namespace Rcpp;
  
  //[[Rcpp::export]]
  NumericVector naLocf(NumericVector x) {
    int n=x.size();
    for (int i=1;i&lt;n;i++) {
      if (R_IsNA(x[i]) &amp; !R_IsNA(x[i-1])) {
        x[i]=x[i-1];
      }
    }
    return x;
  }
  </code></pre>
  
  <p>I was just wondering that since these are quite basic functions, someone might have already implemented them in <code>RCpp</code> in a better way (may be avoid the loop) OR a faster way?</p>