[R-SIG-Finance] Extracting Interval-Based Data From Zoo Series

Dirk Eddelbuettel edd at debian.org
Mon Dec 10 13:11:49 CET 2007


On 10 December 2007 at 10:57, Rory Winston wrote:
| 1. I can see that as.POSIXct() can deal with millisecond resolution, but zoo
| doesnt seem to use the millis portion of the timestamp as an index variable.

It can, but you have to enable the printing:

> zz <- zoo(matrix(1:6, ncol=2), order.by=Sys.time() + seq(0,2)*1e-4)
> zz

2007-12-10 06:06:46 1 4
2007-12-10 06:06:46 2 5
2007-12-10 06:06:46 3 6
> options("digits.secs"=6)
> zz

2007-12-10 06:06:46.898058 1 4
2007-12-10 06:06:46.898158 2 5
2007-12-10 06:06:46.898258 3 6


That is a major bonus for high-frequency data -- POSIXt has a native
resolution to a microsecond.

| 2. What I would like to do with the data, is extract and aggregate
| sub-series. So for the tick data above, if I wanted to check for diurnal
[...]
| Is it possible to do this in a neater way? I tried using rollapply() to get
| a daily rolling window, but wasnt successful.

Because it is a 'native' format, you get to do all possible zoo tricks.

Hth, Dirk

-- 
Three out of two people have difficulties with fractions.



More information about the R-SIG-Finance mailing list