[R-SIG-Finance] mark random rows of xts object

Andreas Voellenklee wotuzu17 at gmail.com
Thu May 17 14:01:08 CEST 2012


Hi,

To compare results of a trading system against a
random-entry-benchmark, I'm trying to program a function that marks
random 5% of bars of a xts object.

The result should be a xts object with the same indexes as the OHLCV
object and one column "random_entry" that contains boolean values.

I tried this without success:


# returns true in 5% of calls
random <- function() {runif(1,0,1) >= .95}

getSymbols("MMM")

> as.xts(apply(MMM, 1, random))
Fehler in FUN(newX[, i], ...) : unbenutzte(s) Argument(e) (newX[, i])


Thanks for your help,
Andreas



More information about the R-SIG-Finance mailing list