Here are some more seq.dates examples from chron. It seems that if seq.Date cannot output day of the month n (because the month has fewer days) then it outputs n days from the start of the month even if that goes into the next month whereas seq.dates in chron outputs the end of the month in that case.
> library(chron) > seq(chron("01/31/2006"), by = "month", length = 6) [1] 01/31/06 02/28/06 03/31/06 04/30/06 05/31/06 06/30/06 > seq(chron("01/30/2006"), by = "month", length = 6) [1] 01/30/06 02/28/06 03/30/06 04/30/06 05/30/06 06/30/06 > seq(chron("01/29/2006"), by = "month", length = 6) [1] 01/29/06 02/28/06 03/29/06 04/29/06 05/29/06 06/29/06 > seq(chron("01/28/2006"), by = "month", length = 6) [1] 01/28/06 02/28/06 03/28/06 04/28/06 05/28/06 06/28/06 > seq(chron("01/27/2006"), by = "month", length = 6) [1] 01/27/06 02/27/06 03/27/06 04/27/06 05/27/06 06/27/06 On 8/4/06, Martin Maechler <[EMAIL PROTECTED]> wrote: > >>>>> "Gabor" == Gabor Grothendieck <[EMAIL PROTECTED]> > >>>>> on Thu, 3 Aug 2006 20:14:24 -0400 writes: > > Gabor> That's, in fact, the way seq.dates works in the chron package: > Gabor> library(chron) > Gabor> x <- chron("01/31/2006") > Gabor> seq(x, by = "month", length = 2) # 01/31/06 02/28/06 > > Hmm, so, by "logic", > 2006-01-31 + 1month |-> 2006-02-28 > 2006-01-30 + 1month |-> 2006-02-27 (?) > 2006-01-29 + 1month |-> 2006-02-26 (?) > 2006-01-28 + 1month |-> 2006-02-25 ???????? > > I really don't like 'chron's behavior which seems much less > logical to me than what R does with the official "Date" objects : > > > options(width=88) > > for(d in 28:31) print(seq(as.Date(paste("2006-01", d, sep="-")), len = 6, > > by="1 month")) > [1] "2006-01-28" "2006-02-28" "2006-03-28" "2006-04-28" "2006-05-28" > "2006-06-28" > [1] "2006-01-29" "2006-03-01" "2006-03-29" "2006-04-29" "2006-05-29" > "2006-06-29" > [1] "2006-01-30" "2006-03-02" "2006-03-30" "2006-04-30" "2006-05-30" > "2006-06-30" > [1] "2006-01-31" "2006-03-03" "2006-03-31" "2006-05-01" "2006-05-31" > "2006-07-01" > > > > {which, BTW, *is* reproducible code; the bug report was only > reproducible on the day it was posted because it sillily used > Sys.date()} > > Gabor> See the help desk article in R News 4/1 for more about the main > Gabor> date classes. > > Gabor> On 8/3/06, Ponzio, Stephen [CIB-LAVA] <[EMAIL PROTECTED]> wrote: > >> You're right, it's tricky. > >> > >> I guess I would expect Jan. 30 + 1 month = Feb. 28. > >> > >> Of couse, then Jan. 30 + 1 month = Jan. 28 + 1 month; > >> I understand. > >> > >> Being that "1 month" is imprecise in terms of number of days, > >> this anomaly is preferable to skipping months (Jan. 30 + 1 month = > March 2), > >> in my opinion. > >> > >> That is what I expected, anyway. > >> > >> Thanks, > >> Stephen > > [.........] > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel