title: Cumulative average for a specific value
body: <p>I want to calculate a cumulative average only if the value is >0. If I have a vector:</p>
  
  <pre><code>v &lt;- c(1, 3, 0, 3, 2, 0)
  </code></pre>
  
  <p>The average would be 9/6 = 1.5,  however I only want to take an average when the value is >0, so in this case it would be 9/4 = 2.25.  But that average is over the entire set. I want to do this averaging as the data set builds and accumulates.  So, initially it would be:</p>
  
  <pre><code>1+3/2, 1+3+0/2, 1+3+0+3/3, 1+3+0+3+2/4, 1+3+0+3+2+0/4
  </code></pre>
  
  <p>My data set is 9,000 rows and its growing. I can get <code>cumsum</code> to work and calculate the cumulative sum, but not the cumulative average for a "success".</p>