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

2021-01-07 Thread Jeremie Juste
Hello Dirk, Many thanks for the feedback. I did came across your SO answer but didn't know the RcppBDT package, thanks for pointing that out. Best regards, Jeremie On Thursday, 7 Jan 2021 at 13:59, Dirk Eddelbuettel wrote: > Jeremie, > > As months have irregular number of dates, one needs to

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

2021-01-07 Thread Jeremie Juste
Hello Jim, Many thanks for the feedback > 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. Indeed I missed the documentation of seq.Date that refers to seq.POSIXt.

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

2021-01-07 Thread Dirk Eddelbuettel
Jeremie, As months have irregular number of dates, one needs to use a function that accounts for that (date libraries and packages have that, one of the earliest for R was my RcppBDT package using Boost Date_Time), or be otherwise clever. Here is a one-liner using the latter approach:

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

2021-01-07 Thread jim holtman
yes it is the expected behaviour is you check the documentation: 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. Jim Holtman Data Munger Guru What is the problem that

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

2021-01-07 Thread Jeremie Juste
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