I want to use moving average function (rollmean) in R. Example data:
x<-seq(1,48,by=1)
y<-c(rep(11,12), rep(12,12))
z<-data.frame(x,y)
I want to calculate moving average of the z[,"x"] with lag of 3 days for each z[,"y"] (i.e. 11 & 12) and filled them to the (new) third column where first two rows of each z[,"y"] are designated by NAs.