[R] without the loop

Omar Lakkis uofiowa at gmail.com
Fri May 13 22:58:42 CEST 2005


Can this be re-implemented to run faster (without the loop) ? 

r <- list()
n = nrow(prices)
        for (i in (w+1):n) {                   
                window <- prices[(i-w):(i-1),]                              
                if (prices[i,]$settle > max(window$high)) r <-
append(r,  1)
                else if (prices[i,]$settle < min(window$low)) r <-
append(r, -1)
        }




More information about the R-help mailing list