Adding a month on with a '+' is fairly straightforward.
Code:
library(lubridate)
ymd("2018-01-01") + months(1)
Output:
[1] "2018-02-01"
Using %m+%
doesn't appear to be doing any different in this case.
Code:
ymd("2018-01-01") %m+% months(1)
Output:
[1] "2018-02-01"
However in this example, we fail to add a month on as there is no 31st of February.
Code:
ymd("2018-01-31") + months(1)
Output:
[1] NA
Therefore, we need to use the %m+%
operator instead.
Code:
ymd("2018-01-31") %m+% months(1)
Output:
[1] "2018-02-28"