title: R Take Updated Maximum
body: <p>Sample Data</p>
  
  <pre><code>data =data.frame(id=c(1,1,1,2,2,2,3,3,3,4,4,4),
                   score=c(5,7,6,9,8,4,NA,11,3,7,NA,10),
                   WANT=c(5,7,7,9,9,9,NA,11,11,7,7,10))
  </code></pre>
  
  <p>Basically WANT should be equals to the maximum value of score at each row for each ID. As you can see it updates. This is my attempt but it does not handle the NA values.</p>
  
  <pre><code>data$WANT &lt;- ave(data$score, data$id, FUN=!is.na(cummax))
  </code></pre>