I am using The timeBasedSeq function from xts package to use as index in a time series/zoo object but it repeats some of the days it creates! Which than causes problems with zoo because the “index entries in ‘order.by’ are not unique”.
For example:
timeBasedSeq(“19860601/19861231”)
will create
…”1986-10-23″ “1986-10-24” “1986-10-25” “1986-10-26” “1986-10-26” “1986-10-27” “1986-10-28” “1986-10-29″”…
So for some reason it repeats the 26th, how can I avoid that?
The bug is in xts. That function uses
seq.POSIXct, and the same behavior can be produced by:And even more surprising to me by
seq.POSIXltBut that behavior is well documented in seq.POSIXt and there is a provision for using
by="DSTday"which the xts authors should probably have used for the situation when days are the implicit interval. The temporary workaround is:or more compactly: