Skip to content
Prev 58979 / 398502 Next

unavoidable loop? a better way??

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