1

Why does this timeBasedSeq result in repeated 31st of October?

> d <- timeBasedSeq("2010-05-24/2010-11-04/d")
> d[158:164]
 [1] "2010-10-28" "2010-10-29" "2010-10-30" "2010-10-31"
 [5] "2010-10-31" "2010-11-01" "2010-11-02"

Using Package xts version 0.9-7 on R 3.1.2

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
mark
  • 537
  • 6
  • 25
  • Usually the answer to time related hiccups in Spring or Fall is is "Daylight Savings time". When did that happen in your locale in 2010? For me in the US I get a double date on `"2010-11-07" "2010-11-07"` – IRTFM Apr 01 '15 at 23:16
  • @BondedDust just checked for UK and it was.. 31st Oct in 2010. Can this be sorted in xts /resetting locale or just manual correction? – mark Apr 01 '15 at 23:22
  • If I were doing this, I would use `seq.Date` – IRTFM Apr 01 '15 at 23:31
  • Sorted. `dd <- seq.Date(as.Date("2010-05-24"),as.Date("2010-11-04"), 1)`. @BondedDust you want to post an answer for me to tick? – mark Apr 01 '15 at 23:35

1 Answers1

2

I think it's a bug (paging @JoshuaUlrich). Happens when start date is in DST and ends in std-time:

> xts::timeBasedSeq('20080101/20081109/d')[duplicated(xts::timeBasedSeq('20080101/20081109/d'))]
character(0)
> xts::timeBasedSeq('20080701/20081109/d')[duplicated(xts::timeBasedSeq('20080701/20081109/d'))]
[1] "2008-11-02"

And in a different year:

> xts::timeBasedSeq('20100701/20101109/d')[duplicated(xts::timeBasedSeq('20100701/20101109/d'))]
[1] "2010-11-07"
> xts::timeBasedSeq('20100101/20101109/d')[duplicated(xts::timeBasedSeq('20100101/20101109/d'))]
character(0)

> dd <- seq(as.Date('2010-07-01'), as.Date('2010-11-04') ,1)
> dd[ duplicated(dd) ]
character(0)

Sent report to:

>  maintainer('xts')
[1] "Jeffrey A. Ryan <jeff.a.ryan@gmail.com>"
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Thanks. Jeff likely won't respond, but I will. :) This looks similar to something you reported to us years ago... but was never fixed. I guess it's time to fix it. – Joshua Ulrich Apr 02 '15 at 01:19
  • I reported it? Must have been in response to an SO question then ... I don't use xts, not because of any deficiency ... it's just not related to health statistics. – IRTFM Apr 02 '15 at 01:25
  • You did, via email. And it was in response to the question I marked this as a duplicate of. – Joshua Ulrich Apr 02 '15 at 01:30
  • 1
    Huh. Look at that. I even showed you how to fix it. Completely forgot about that. – IRTFM Apr 02 '15 at 01:33
  • You did, and I appreciate it. I just added it as [xts issue #67](https://github.com/joshuaulrich/xts/issues/67) on GitHub. I need to look at `timeBasedSeq` and evaluate your patch, but I should be able to do that in the next few days. Thanks again! – Joshua Ulrich Apr 02 '15 at 01:36