我想从csv文件加载时间序列数据。如果可以使用ts()
函数,我感到很困惑?
数据如下所示:
time(ms),value
1390933817000,3775.89624023438
1390933847000,3765.65698242188
1390933877000,3757.01416015625
1390933907000,3768.63623046875
1390933937000,3775.84497070312
1390933967000,3774.53588867188
1390933997000,3771.6240234375
1390934027000,3763.83081054688
如您所见,该值每30秒获取一次。
答案 0 :(得分:0)
试试这个(注释):
Lines <- "time(ms),value
1390933817000,3775.89624023438
1390933847000,3765.65698242188
1390933877000,3757.01416015625
1390933907000,3768.63623046875
1390933937000,3775.84497070312
1390933967000,3774.53588867188
1390933997000,3771.6240234375
1390934027000,3763.83081054688"
library(zoo)
# z <- read.zoo("myfile.dat", sep = ",", header = TRUE, FUN = identity)
z <- read.zoo(text = Lines, sep = ",", header = TRUE, FUN = identity)
as.ts(z)