A quick question about dates in R. Check out this piece of code:
Sys.Date() - months(3) # [1] "2013-12-31" Sys.Date() - months(18) # [1] NA
I downloaded the lubridate package and followed the instructions provided , and I cannot unwittingly discuss this behavior. It worked very well, on the first day today, when I noticed that subtracting more than 12 months from today gives NA profitability (subtracting less than 12 months works great).
I would be grateful if someone could explain to me why this does not work, and / or suggest a more "reliable" way to get around this. Is this connected with the last day of the month (day 31)?
I ask because this works:
Sys.Date() - years(2) # [1] "2012-03-31"
date r lubridate
PMaier
source share