[R] unavoidable loop? a better way??

James Muller james.muller at anu.edu.au
Sat Nov 13 08:08:50 CET 2004


I am very sorry. I've made a typo. The function should be:

# p is a vector
myfunc <- function (p) {
   x[1] <- p[1]
   for (i in c(2:length(p))) {
     x[i] <- 0.8*p[i] + 0.2*x[i-1]
   }
   return (x)
}


James




More information about the R-help mailing list