Skip to content
Prev 81992 / 398506 Next

values in between

Eric C. Jennings wrote:
Hi Eric,

There was a function "filter" in the ts package, but that package seems 
to have disappeared. A Q&D function that would do what you want is:

wapply<-function(x,window=2,FUN=mean,mode="numeric",...) {
  w1<-window-1
  l1<-length(x)-w1
  wout<-vector(mode,l1)
  for(i in 1:l1) wout[i]<-do.call(FUN,list(x=x[i:(i+w1)]))
  return(wout)
}

Jim