I wanted to use cummean
by groups ignoring NA
. Here is the sample data.
data.frame(group1 = c(rep(1,3),rep(2,3),rep(3,3)),
val = c(c(NA,4,5),c(NA,NA,5),c(1,NA,3)))
How can I get cumulative mean by group ignoring NA
?
Here is my desired out
c(NA,4,4.5,NA,NA,5,1,1,2)