Hi what the randPos() function does is apply the .randPos() function "nrow(x)" times so the result is a vector of the same length as x. Of that result, only the last value is used in the strategy, i think. All the results are the same. so "i" is just a counter that the 'sapply' function needs. It does not do anything else.
Looking at it agin now, I am thinking that this is a particularly ugly way of doing this. maybe just use "rep" instead of "sapply". see ?rep and ?sapply ----- http://censix.com -- View this message in context: http://r.789695.n4.nabble.com/Quantstrat-Error-while-applying-strategy-tp3472438p4326718.html Sent from the Rmetrics mailing list archive at Nabble.com. _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
