Skip to content
Back to formatted view

Raw Message

Message-ID: <loom.20041104T174642-615@post.gmane.org>
Date: 2004-11-04T17:27:14Z
From: Gabor Grothendieck
Subject: problems with seq.dates

<Ciprian_Marin <at> ssga.com> writes:

: 
: There seem to be a bug in the seq.dates function in the chron package for R
: 2.0. Please see below:
: 
: when the specified frequency is "months", seq.dates does not return the end
: of the specified interval all the time:
: 
: > seq.dates(from = "05/31/04", to = "12/31/04", by = "months")
: [1] 05/31/04 06/30/04 07/31/04 08/31/04 09/30/04 10/31/04 11/30/04
: 


This is a bug.  A workaround is to place the to= date after the 
last date you want in your sequence rather than right at it:

seq.dates(from = "05/31/04", to = chron("12/31/04")+1, by = "months")


You can fix your copy of seq.dates by inserting, after these 3 lines:

    if (by == "months") {
        nxt.day <- month.day.year(as.numeric(from + 1))$month
        end.of.the.month <- frm.mdy$month != nxt.day

the following line:

        if (end.of.the.month) x <- c(x, x[length(x)]+1)