title: Cummean column-wise and ignoring NAs
body: <p>I have a data frame looking like this:</p>
  
  <pre><code>as.data.frame(matrix(c(1,2,3,NA,4,5,NA,NA,9), nrow = 3, ncol = 3))
    V1 V2 V3
  1  1 NA NA
  2  2  4 NA
  3  3  5  9
  </code></pre>
  
  <p>I would like to calculate a cumulative mean per column, which ignores NAs, so something like this:</p>
  
  <pre><code>  V1 V2 V3
  1  1 NA NA
  2  3  4 NA
  3  6  9  9
  </code></pre>
  
  <p>I tried this: </p>
  
  <pre><code>B[!is.na(A)] &lt;- as.data.frame(apply(B[!is.na(A)], 2, cummean))
  </code></pre>
  
  <p>But received this error message: </p>
  
  <blockquote>
    <p>dim(X) must have a positive length</p>
  </blockquote>
  
  <p>Thanks for your help!</p>
  
  <p>Cheers</p>