lubridate error message 'incompatible method's when trying date arithmetic

Posted by Sharon on Stack Overflow See other posts from Stack Overflow or by Sharon
Published on 2013-08-18T13:35:20Z Indexed on 2013/10/22 3:54 UTC
Read the original article Hit count: 592

Filed under:
|

I'm trying to learn lubridate. The lubridate documentation shows:

date <- ceiling_date(date, "month") - days(1)
[1] "2010-05-31 UTC

for date arithmetic. But if I try

mytoday <- now()
first_of_month <- floor_date(mytoday, "month")
first_of_month_last_year <- first_of_month - years(1)

to use date arithmetic to get the first of the month a year earlier I get an error message

Warning message:
Incompatible methods ("-.POSIXt", "Ops.ordered") for "-" 

Any ideas what I'm doing wrong? Thanks.

© Stack Overflow or respective owner

Related posts about r

    Related posts about lubridate