Skip to content
Prev 7416 / 15274 Next

XTS with unique time stamps?

Brian, Worik

w.r.t the new functionality in xts.

It is so bleeding edge that Brian gave you the wrong name ;-) think
"make [the] index unique".  It probably will also be extended to do
the former removal of subsequent non-unique observations/times as
well.

HTH,
Jeff


?make.index.unique

make.index.unique             package:xts              R Documentation

Force Time Values To Be Unique

Description:

     A generic function to force sorted time vectors to be unique.
     Useful for high-frequency time-series where original time-stamps
     may have identical values. For the case of xts objects, the
     default ?eps? is set to one-hundred microseconds. In practice this
     advances each subsequent identical time by ?eps? over the previous
     (possibly also advanced) value.

Usage:

     make.index.unique(x, eps = 1e-05, ...)

     make.time.unique(x, eps = 1e-05, ...)

Arguments:

       x: An xts object, or POSIXct vector.

     eps: value to add to force uniqueness.

     ...: unused

Details:

     The returned time-series object will have new time-stamps so that
     ?isOrdered( .index(x) )? evaluates to TRUE.

Value:

     A modified version of x.

Note:

     Incoming values must be pre-sorted, and no check is done to make
     sure that this is the case.  If the index values are of
     storage.mode ?integer?, they will be coerced to ?double?.

Author(s):

     Jeffrey A. Ryan

See Also:

     ?align.time?

Examples:

     ds <- options(digits.secs=6) # so we can see the change

     x <- xts(1:10, as.POSIXct("2011-01-21") + c(1,1,1,2:8)/1e3)
     x
     make.index.unique(x)

     options(ds)
On Mon, Jan 31, 2011 at 6:05 AM, Brian G. Peterson <brian at braverock.com> wrote: