[R] seq.Date when date is the last date of the month

Jeremie Juste jerem|eju@te @end|ng |rom gm@||@com
Thu Jan 7 20:18:36 CET 2021


Hello,

I recently bumped into a behavior that surprised me.
When performing the following command, I would expect the second
argument to be "2012-09-30" but got "2012-10-01" instead
> seq(as.Date("2012-08-31"),by="1 month",length=2)
[1] "2012-08-31" "2012-10-01"

When the same command is performed for the start of the month. I get a
result I expect.
> seq(as.Date("2012-08-01"),by="1 month",length=2)
[1] "2012-08-01"


Is there an explanation for this behavior?

Best regards,
-- 
Jeremie Juste



More information about the R-help mailing list