Change the year in a datetime object in R?

前端 未结 3 703
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 08:53

I have the following:

\"0014-06-30\"

And I\'d like to change it to:

\"0000-06-30\"

How would I do this in

3条回答
  •  醉酒成梦
    2020-12-18 09:11

    > x <- as.Date('0014-06-30')
    > x
    [1] "0014-06-30"
    > library(lubridate)
    > year(x)
    [1] 14
    > year(x) <- 0
    > x
    [1] "0000-06-30"
    

提交回复
热议问题