在R中的日期时间对象中更改年份? [英] Change the year in a datetime object in R?
本文介绍了在R中的日期时间对象中更改年份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
"0014-06-30"
我想将其更改为:
"0000-06-30"
我将如何在R中执行此操作?
How would I do this in R?
我正在阅读的所有内容都非常专注于将字符串转换为日期,而不是围绕日期内的元素进行更改。
Everything that I'm reading is very focused on converting strings to dates rather than changing around the elements inside a date.
推荐答案
> 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"
这篇关于在R中的日期时间对象中更改年份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文