[R-SIG-Finance] mark random rows of xts object
Brian G. Peterson
brian at braverock.com
Thu May 17 14:10:25 CEST 2012
On Thu, 2012-05-17 at 14:01 +0200, Andreas Voellenklee wrote:
> 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.
getSymbols('MMM')
MMM$random<-0
MMM$random[sample(1:nrow(MMM),round(nrow(MMM)/20),replace=FALSE),]<-1
Regards,
- Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list