I use lubridate and figured that this would be so easy
ymd("2010-01-31")+months(0:23)
But look what one gets. It is all messed up!
[1] "2010-01-31 UTC" "2010-03-03 UTC" "2010-03-31 UTC" "2010-05-01 UTC" "2010-05-31 UTC" "2010-07-01 UTC" "2010-07-31 UTC" "2010-08-31 UTC" "2010-10-01 UTC"
[10] "2010-10-31 UTC" "2010-12-01 UTC" "2010-12-31 UTC" "2011-01-31 UTC" "2011-03-03 UTC" "2011-03-31 UTC" "2011-05-01 UTC" "2011-05-31 UTC" "2011-07-01 UTC"
[19] "2011-07-31 UTC" "2011-08-31 UTC" "2011-10-01 UTC" "2011-10-31 UTC" "2011-12-01 UTC" "2011-12-31 UTC"
Then I read how lubridate caters to phenomenon such as interval, duration and period. So, OK I realize that a month is actually the number of days defined by (365*4+1)/48 = 30.438 days. So I tried to get smart and rewrite it as
ymd("2010-01-31")+ as.period(months(0:23))
But that just gave an error.
Error in as.period.default(months(0:23)) : (list) object cannot be coerced to type 'double'
strftime(date)
to get rid of the timezone. sostrftime('2010-10-31 UTC')
would give you2010-10-31
. – Yellowbird