2014-04-07 22 views
1

出生日期来自同一文件并且长度相同。日期格式似乎很好。但xts不能识别它为日期,为什么?!谢谢你的帮助!为什么R中的“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” 
+0

什么是str的输出执行胎<现有的(日期)和STR(产) - XTS(产) – Thierry

回答

0

dates是1列data.frame。 as.Date和xts'order.by参数需要载体。

births <- xts(births, dates$Month) 
+0

它不工作!非常感谢!!! – Chen

相关问题