Hi

I am trying to compare two elements in an xts object. Is the following way
wrong? Prices contain data of a price series. Thx for the help.


> prices$Open[7]
             Open
1995-11-13 949.29
> prices$Close[6]
            Close
1995-11-10 948.82
> if (prices$Open[7]< prices$Open[6]) 1 else 0
Error in if (prices$Open[7] < prices$Open[6]) 1 else 0 :
  argument is of length zero
> str(prices)
An ‘xts’ object from 1995-11-03 to 2010-07-02 containing:
  Data: num [1:3637, 1:5] 1000 1002 987 976 960 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:5] "Open" "High" "Low" "Close" ...
  Indexed by objects of class: [POSIXt,POSIXct] TZ:
  xts Attributes:
 NULL


-- 
'Raghu'

	[[alternative HTML version deleted]]

