title: How to count number of TRUE values in a logical vector before FALSE
body: <p>While trying to find number of <code>TRUE</code> values in a vector, I came across the first   <a href="https://stackoverflow.com/questions/2190756/how-to-count-true-values-in-a-logical-vector">Google hit</a>. However, this does not fully meet my requirements. I am interested to find the number of <code>TRUE</code> values in a vector before the first <code>FALSE</code> if any.  I have a vector <code>a &lt;- c(TRUE,TRUE,TRUE,FALSE,TRUE, TRUE)</code> and want to find all <code>TRUE</code> values before the <code>FALSE</code>, so output will be three. Kindly note that it should also work if there are only <code>TRUE</code> values in the vector. </p>