Hello,

I coming across a strange problem doing math on an xts object.

If I have an xts object of stock prices (perhaps 5 minute bars of open, high, 
low,close) and want to do some math, the results fail.

For example:

d$close[10] - d$open[10] works perfectly

d$close[10] - d$open[9] fails.  I just get an answer of "numeric(0)  Index: 
numeric(0)".

My guess is that xts is breaking because the two items in my equation have 
different time stamps.  However, the actual data is correct, and the xts matrix 
looks correct.

Note:  It works if I do things the loooong way around.
as.numeric(d$close[10]) - as.numeric( d$open[9] )

But, that is horrendously slow.

Suggestions?

--
Noah Silverman, C.Phil
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to