如何将POSIX日期转换为R中的一年? [英] How do you convert POSIX date to day of year in R?
本文介绍了如何将POSIX日期转换为R中的一年?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
另一种方法是使用 strftime()
格式化POSIXt
对象:
R>今天< - Sys.time()
R>今天
[1]2012-10-19 19:12:04 BST
R> doy< - strftime(今天,格式=%j)
R> doy
[1]293
R> as.numeric(doy)
[1] 293
其中最好记住这几年的日子是以POSIX标准为零。
The title has it: how do you convert a POSIX date to day-of-year?
解决方案
An alternative is to format the "POSIXt"
object using strftime()
:
R> today <- Sys.time()
R> today
[1] "2012-10-19 19:12:04 BST"
R> doy <- strftime(today, format = "%j")
R> doy
[1] "293"
R> as.numeric(doy)
[1] 293
which is preferable to remembering that the day of the years is zero-based in the POSIX standard.
这篇关于如何将POSIX日期转换为R中的一年?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文