【发布时间】:2011-07-31 00:32:26
【问题描述】:
我正在尝试使用 R timeSeries 包来读取 csv 文件。
这是我要运行的代码:
prices <- readSeries(file='A2006-2011.csv',head=T,sep=",",format="%m/%d/%Y")
但是,它不能识别 csv 中的日期(下面是它的前几行)
Date Open High Low Close Volume Adj.Close
4/4/2011 45.07 45.41 44.36 44.83 2133900 44.83
4/1/2011 44.88 45.48 44.78 45.14 2212300 45.14
3/31/2011 44.92 45.02 44.46 44.78 2194900 44.78
3/30/2011 44.79 45.17 44.65 45.09 2514100 45.09
它会打印以下警告:
Warning message:
In readSeries(file = "A2006-2011.csv", head = T, sep = ",", format = "%m/%d/%Y") :
Conversion of timestamps to timeDate objects produced only NAs.
Are you sure you provided the proper format with argument 'format'
or in the header of your file ?
如果有人可以帮助我,我将不胜感激。
【问题讨论】:
-
即使您的文件中似乎没有逗号,您使用逗号作为字段分隔符是否正确?
标签: datetime r file-io posix time-series