2014-04-21 50 views
-2

X = read.csv(file.choose())中的R quantmod错误

头(X)

Date  Open High Low Close Volume 
1 2013/1/2 13257 13289 13162 13194 168353 
2 2013/1/3 13195 13198 13055 13055 242457 
3 2013/1/4 13050 13100 13005 13079 256215 
4 2013/1/7 13085 13128 13025 13126 228488 
5 2013/1/8 13136 13148 13064 13088 227064 
6 2013/1/9 13091 13104 13044 13072 219862 

库(quantmod)

BARCHART(X)

在try.xts错误(x,error =“chartSeries需要一个非法对象”): chartSeries需要一个非法对象

+0

你能解释一下更清楚你想要达到什么样的? – Jaap

+1

将'x'转换为xts或转换为与'as.xts'一起使用的data.frame。 –

+0

step1.write .zoo step2。 as.xts – user3556887

回答

1

你可以在一行中完成。假设您正在加载的文件在您的“数据”目录中名为“spy.csv”,并保存SP500 OHLC数据。

spy <-as.xts(read.zoo("~/data/spy.csv",header=TRUE,sep=",",colClasses = c("Date", rep("numeric",4)))) 

barChart(SPY) 

会显示您的图表中的所有它的荣耀:-)

0

如果我们假设该文件的名称是全球植物保护战略,通过加载解决方案,我们会得到!

Error in file(file, "rt") : cannot open the connection 

另外:警告消息:

In file(file, "rt") : 
cannot open file 'GSPC.csv': No such file or directory ====> my file is existed !!!