From murdoch.duncan at gmail.com  Tue Jan 31 21:17:42 2012
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Tue, 31 Jan 2012 15:17:42 -0500
Subject: [Rd] seq.Date bug?
In-Reply-To: <20264.18292.474587.518409@max.nulle.part>
References: <20264.18292.474587.518409@max.nulle.part>
Message-ID: <4F284C66.2020409@gmail.com>

On 12-01-31 2:56 PM, Dirk Eddelbuettel wrote:
>
> R>  seq(as.Date(Sys.Date()), by="-1 months", length=6)
> [1] "2012-01-31" "2011-12-31" "2011-12-01" "2011-10-31" "2011-10-01" "2011-08-31"
> R>
>
> Notice how October appears twice.

>
> Now, date arithmetic is gruesome but the documentation for seq.Date et al
> does not hint it wouldn't honour the by= argument.  So a bug, or merely a
> somewhat less than desirable features.

It is giving you Jan 31, Dec 31, Nov 31, Oct 31, Sep 31, Aug 31 -- 
except some of those months don't have 31 days, so it is converting 
those dates to ones that really exist.  (This is documented in ?seq.POSIXt.)

Isn't this what you asked for?

Duncan Murdoch


>
> (And yes, I think I know that Hadley's lubridate has code for this too, but
> so may my RcppBDT which is sitting on top of Boost::DateTime code ...)
>
> Dirk
>



[Rd] seq.Date bug?
Duncan Murdoch