Hello, 2 xts/zoo questions:

1) experiencing a behavior i can't explain with zoo or xts objects and 
can't seem to rectify

Dividing two zoo or xts objects and I don't get the result as a zoo or 
xts object, i get a number vector with no time index,  pulling my hair 
on this, any recommendations?

 > str(XJZLN.X)
'zoo' series from 2009-10-06 09:30:07 to 2009-10-06 15:59:54
  Data: num [1:2813] 0 0 0 0 0 0 0 0 0 0 ...
  Index:  POSIXct[1:2813], format: "2009-10-06 09:30:07" "2009-10-06 
09:30:15" ...

 > str(XJZXN.X)
'zoo' series from 2009-10-06 09:30:07 to 2009-10-06 15:59:54
  Data: num [1:2813] 0 0 0 0 0 0 0 0 0 0 ...
  Index:  POSIXct[1:2813], format: "2009-10-06 09:30:07" "2009-10-06 
09:30:15" ...

# fixing the division by zero in the dataset, inserting a constant
 > dec14callput = ifelse(is.nan(XJZLN.X / XJZXN.X),2.23,XJZLN.X / XJZXN.X)

#however the resulting object is not zoo anymore? 
 > str(dec14callput)
 num [1:2813] 2.23 2.23 2.23 2.23 2.23 2.23 2.23 2.23 2.23 2.23 ...

ok lets try coercing to a zoo, but now we lose the index?

 > dec14callput = zoo(ifelse(is.nan(XJZLN.X / XJZXN.X),2.23,XJZLN.X / 
XJZXN.X))

'zoo' series from 1 to 2813
  Data: num [1:2813] 2.23 2.23 2.23 2.23 2.23 2.23 2.23 2.23 2.23 2.23 ...
  Index:  int [1:2813] 1 2 3 4 5 6 7 8 9 10 ...


2) How does one subset only hours from an XTS (or zoo) object across 
many days.  I have some ticker data from 10/1/2009 thru 10/8/2009 for 
example.  It is data that contains pre /post session data as well as the 
active trading session.  I want to pull from 9:30 to 4:00 only across 
ALL the dates, in an elegant way.

I have tried window as well as the :: operator for XTS, no luck.

Something like this i was trying for a ZOO object: 

tmpfile <- window(XJXLN.X, start = as.POSIXct(("XXXX-XX-XX 
09:30:00"),end = as.POSIXct("XXXX-XX-XX 16:00:00")))

Any type of wildcard for the dates, so given any date, but only pull 
rows that are between 9:30 and 16:00. 




	[[alternative HTML version deleted]]

