search for: buysiz

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

Did you mean: bufsiz
2011 Jan 10
2
Aggragating subsets of data in larger vector with sapply
...dd up the buys for each second, the code works but it is very slow. Any suggestions how to improve the sapply function ? secEP = endpoints(xSym$Direction, "secs") # vector of last second on an XTS timeseries object with multiple entries for each second. d = xSym$Direction s = xSym$Size buySize = sapply(1:(length(secEP)-1), function(y) { i = (secEP[y]+ 1):secEP[y+1]; # index of vectors between each secEP return(sum(as.numeric(s[i][d[i] == "buy"]))); } ) Object details: secEP = numeric Vector of one second Endpoints in xSym$Direction. > head(xSym$Direction)...