我有一个csv,这个数据用于我用read.csv读取的特定日期
160525.000,38.63
160526.086,38.63
160526.604,38.62
160526.710,38.63
160526.343,38.62
date = "20150824"
我将第一列转换为datetime:
idx=strptime(paste(date,Data[,1]),"%Y%m%d %H%M%OS")
获取
"2015-08-24 16:05:25.000 GMT" "2015-08-24 16:05:26.086 GMT"
"2015-08-24 16:05:26.604 GMT" "2015-08-24 16:05:26.710 GMT"
"2015-08-24 16:05:27.343 GMT"
我使用:
构造xts对象data=as.xts(Data[,-1],order.by=idx)
获取数据
> head(data)
V2
2015-08-24 16:05:25.000 38.63
2015-08-24 16:05:26.085 38.63
2015-08-24 16:05:26.604 38.62
2015-08-24 16:05:26.710 38.63
2015-08-24 16:05:27.342 38.62
您会注意到某些行(2,5)的xts对象的时间索引为false。 我没找到原因?
这是我的R会议的信息
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] highfrequency_0.4-1 PerformanceAnalytics_1.4.3662 plsgenomics_1.3-1 boot_1.3-16
[5] MASS_7.3-40 quantmod_0.4-5 TTR_0.23-0 xts_0.9-7
[9] zoo_1.7-12
loaded via a namespace (and not attached):
[1] timeSeries_3012.100 tools_3.2.0 blotter_0.9.1666 grid_3.2.0 timeDate_3012.100 quantstrat_0.9.1687
[7] lattice_0.20-31
有谁知道这会怎么样?更重要的是如何解决它? ;)
提前致谢