[R-SIG-Finance] Adding milliseconds to zoo object

Gabor Grothendieck ggrothendieck at gmail.com
Wed Dec 26 16:09:31 CET 2007


The time class considerations for zoo are that whatever class you
use must support the methods indicated in ?zoo and the index on
any zoo time series must have unique elements.  If they are not
unique you can jitter them, add small amounts to make
them unique or aggregate them so that multiple non-unique points
are eliminated and replaced with a single point.

If your question is whether you could use ordered pairs as a time
class try the R "complex" class or create your own class.

> library(zoo)
> z1 <- zoo(11:15, complex(real = c(1, 1, 2, 2, 3), imag = c(2, 1, 1, 2, 5)))
> merge(z1, lag(z1))
     z1 lag(z1)
1+1i 12      11
1+2i 11      13
2+1i 13      14
2+2i 14      15
3+5i 15      NA

On Dec 26, 2007 6:01 AM, Yuri Volchik <volchik2000 at list.ru> wrote:
> I've read already some discussions concerning milliseconds as an index in
> zoo index and was wondering if there is a simple solution to differentiate
> ticks which come with 1 second timestamp resolution by adding index for rows
> with the same timestamp.
> One of the solutions would be just to create an index with length of
> nrows(x) and consider them as milli(micro)seconds, so my index will look
> like:
> 2007-12-24 06:14:00.154  22.00
> 2007-12-24 06:14:00.155  22.00
> 2007-12-24 06:15:00.156  22.00
> 2007-12-24 06:15:00.157  22.00
>
> So with solution order of the observations(ticks) is preserved, though the
> solution is not very nice.
> Is there a way to create index in the following way?
> 2007-12-24 06:14:00.154  22.00
> 2007-12-24 06:14:00.155  22.00
> 2007-12-24 06:15:00.001  22.00
> 2007-12-24 06:15:00.002  22.00
>
> So this index will be in effect number(position) of the tick in the second.
>
> Thanks
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list