Adding milliseconds to zoo object
Thanks, very interesting solution, works like magic. The only (very minor) inconvenience are NA's at the end but they can be removed or extrapolated. Thanks once again. -----Original Message----- From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] Sent: Wednesday, December 26, 2007 4:40 PM To: Yuri Volchik Cc: r-sig-finance at stat.math.ethz.ch Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object Even though non-unique times form illegal zoo objects, both zoo() and read.zoo() will allow you to create such illegal zoo objects with a warning, rather than an error, in order to give you a chance to fix them up into legal ones. You can still extract and replace the times in case you want to apply jitter or fixed increments and aggregate.zoo will still work in case you want to summarize all points with the same time into a single point. Here is an example of adding increments via interpolation with numeric times:
library(zoo) z <- zoo(11:15, c(1, 1, 2, 2, 5))
Warning message: In zoo(11:15, c(1, 1, 2, 2, 5)) : some methods for "zoo" objects do not work if the index entries in 'order.by' are not unique
z
1 1 2 2 5 11 12 13 14 15
time(z) <- na.approx(ifelse(duplicated(time(z)), NA, time(z))) z
1 1.5 2 3.5 5 11 12 13 14 15