Subtracting months - issue with last day of month?

后端 未结 3 1108
暗喜
暗喜 2020-12-10 15:50

Quick question on dates in R. Check out this snippet of code:

Sys.Date() - months(3)
# [1] \"2013-12-31\"
Sys.Date() - months(18)
# [1] NA

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 16:10

    Similarly if you want to have an increment of 3 months, it can be done as follows:

    PW_Data_Plan_V1$Month = as.Date(PW_Data_Plan_V1$DOJ) %m+% months(3)
    

提交回复
热议问题