【发布时间】:2014-05-19 11:24:46
【问题描述】:
出生日期和日期来自同一个文件并共享相同的长度。
日期格式似乎很好。但是xts 无法将其识别为日期,为什么?!感谢您的帮助!
dates <- read.xlsx("TimeSeriesCourseworkData.xls", 1,colIndex=1,as.data.frame=TRUE)
dates
Month
1 2009-01-01
2 2009-02-01
3 2009-03-01
4 2009-04-01
............
26 2011-02-01
27 2011-03-01
28 2011-04-01
29 2011-05-01
30 2011-06-01
births <- xts(births, order.by = dates)
# Error in xts(births, order.by = dates) :
# order.by requires an appropriate time-based object
births <- xts(births, order.by = as.Date(dates))
# Error in as.Date.default(dates) :
# do not know how to convert 'dates' to class “Date”
【问题讨论】:
-
str(dates) 和 str(births) 在执行births之前的输出是什么
标签: r math statistics time-series xts