[R] any alternatives for complex for-loops?

Kinoko andzsinszan at gmail.com
Wed Nov 12 14:56:33 CET 2008


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

x <- zoo(1:10)
rollapply(x,width=2, function(xx) complexFn(xx[1],xx[2]))

More information about the R-help mailing list