Gentlemen, Thank you for all your help. This list is really amazing.
Following Erik's hint I have managed to find the answer: complexFn <- function(a,b){ c <- (a+b)/2 return(c) } x <- zoo(1:10) rollapply(x,width=2, function(xx) complexFn(xx[1],xx[2])) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.