title: R replacing zeros in dataframe with next non zero value
body: <p>I have a dataframe with a column containing zero values:</p>
  
  <pre><code>a &lt;- 1:10
  b &lt;- c(1, 0, 0, 0, 0, -1, -1, 0, 0, 1)
  df &lt;- data.frame(a, b)
  df
  </code></pre>
  
  <p>How can I replace the zero values with the last non zero value ie column df$b to be:</p>
  
  <pre><code> 1,-1,-1,-1,-1,-1,-1,1,1,1
  </code></pre>
  
  <p>Thank you for your help.</p>