[R] Bug in seq.date?

Jonne Zutt j.zutt at tudelft.nl
Mon Jun 4 10:06:12 CEST 2007


No, it's not a bug, it matches with the documentation.

see:
  ?seq.POSIXt

     Using '"month"' first advances the month without changing the day:
     if this results in an invalid day of the month, it is counted
     forward into the next month: see the examples.

So, it increases the month first, resulting in:
  01-31, 02-31, 03-31, 04-31, 05-31, etc

Then, for the illegal dates it counts forward.
  04-31 becomes 05-01, etc

Jonne.

On Mon, 2007-06-04 at 09:39 +0200, hadley wickham wrote:
> > seq(as.Date("2000-1-1"), as.Date("2001-1-1"), "months")
>  [1] "2000-01-01" "2000-02-01" "2000-03-01" "2000-04-01" "2000-05-01"
>  [6] "2000-06-01" "2000-07-01" "2000-08-01" "2000-09-01" "2000-10-01"
> [11] "2000-11-01" "2000-12-01" "2001-01-01"
> 
> 
> > seq(as.Date("2000-1-31"), as.Date("2001-1-31"), "months")
>  [1] "2000-01-31" "2000-03-02" "2000-03-31" "2000-05-01" "2000-05-31"
>  [6] "2000-07-01" "2000-07-31" "2000-08-31" "2000-10-01" "2000-10-31"
> [11] "2000-12-01" "2000-12-31" "2001-01-31"
> 
> Is this a bug?
> 
> Hadley
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list