如何从R中的POSIXlt日期对象访问个别属性,如小时,分钟?

时间:2015-08-09 04:29:22

标签: r

sampleDate <- "08/15/2015 00:00"
sampleDateObject <- strptime(sampleDate, "%m/%d/%Y %H:%M")

现在如何从这个sampleDateObject获取日,年,月等?

2 个答案:

答案 0 :(得分:1)

sampleDateObject[['year']]

将返回115,这是1900年之后的年数。详情请见?POSIXlt

答案 1 :(得分:0)

好的,我找到了答案。

sampleDateObject$mon # to access month from 0-11

要访问其他属性,请查看此页面 https://stat.ethz.ch/R-manual/R-devel/library/base/html/DateTimeClasses.html

相关问题