title: R: number of consecutive 1s (from left to right)
body: <p>I have the following vectors pattern in R:</p>
  
  <p>A vector of zeroes and ones (Binary vectors , each with length of 4), for example:</p>
  
  <pre><code>x &lt;- c(1,0,1,1)
  </code></pre>
  
  <p>I would like to find number of consecutive 1(s) (from left to right, that is very important)</p>
  
  <p><strong>Edit:</strong> <br/>
  How to do it for matrix, at which each vector has the pattern mentioned above.<br/>
  Preferably with base functions (and without any Rcpp like solutions)</p>
  
  <p>Any pretty solution without *apply functions?</p>