search for: xtssell

Displaying 1 result from an estimated 1 matches for "xtssell".

Did you mean: russell
2011 May 13
2
More effective calculation for loop
...my head around this. #---------------------------------- #Create the example data dDates <- seq(from=as.Date("1990-01-01"), by="day", length.out=10000); xtsHold <- xts(rep(0, times=10000), order.by=dDates); xtsBuy <- xts(sample(0:1,10000,replace=T), order.by=dDates); xtsSell <- xts(sample(0:1,10000,replace=T), order.by=dDates); print(Sys.time()) #Run the inefficient calculation for (i in 2:length(xtsHold)){ xtsHold[i] <- xtsHold[i-1] + xtsBuy[i-1] - xtsSell[i-1]; } print(Sys.time())#---------------------------------- Thank you very much in advance! Best rega...