ass="op">&lt;-</span> <span class="cn">NA_real_</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Calculate cumsum &amp; replace NA values</span></span></span>
<span class="r-in"><span><span class="fu">calc_cumsum</span><span class="op">(</span><span class="va">x</span>, na.fill <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  [1]  1  3  3  3  8 14 21 29