2

每当我使用所有形式的 getSymbols 和 get.hist.quote 命令时,都会出现错误。错误基本上是:

>getSymbols("AAPL") 
Error in read.table(file = file, header = header, sep = sep, quote = quote, : 
  more columns than column names 

另一个例子:

    >x <- get.hist.quote(instrument = "^gspc", start = "1998-01-01", quote = "Close") 
    trying URL 'http://chart.yahoo.com/table.csv?s=^gspc&a=0&b=01&c=1998&d=4&e=12&f=2013&g=d&q=q&y=0&z=^gspc&x=.csv' 
    Content type 'text/csv' length unknown 
    opened URL 
    downloaded 230 Kb 

Error in read.table(destfile, header = TRUE, sep = ",", as.is = TRUE,  : 
  more columns than column names

所有来源和符号都在发生这种情况。我如何解决它??顺便说一句,相同的命令在其他计算机上工作得很好。使用的包:“quantmod”或“tseries”

运行评论中建议的调试器后,我得到:

> debugonce(read.table)
> getSymbols("AAPL")

Browse[2]> head(readLines(file))
[1] "000fe47"                                               
[2] "Date,Open,High,Low,Close,Volume,Adj Close"             
[3] "2013-05-13,451.51,457.90,451.50,454.74,11319600,454.74"
[4] "2013-05-10,457.97,459.71,450.48,452.97,11948800,452.97"
[5] "2013-05-09,459.81,463.00,455.58,456.77,14231700,456.77"
[6] "2013-05-08,459.04,465.37,455.81,463.84,16878500,460.79"
Browse[2]> tail(readLines(file))
[1] "2007-01-05,85.77,86.20,84.40,85.05,29812200,83.26"
[2] "2007-01-04,84.05,85.95,83.82,85.66,30259300,83.86"
[3] "2007-01-03,86.29,86.58,81.90,83.80,44225700,82.04"
[4] ""                                                 
[5] "0"                                                
[6] ""                                                 

Browse[2]> Q
> 
4

1 回答 1

-2

谢谢你的问题。我无法重现该错误。我的文件下载正确并且阅读良好。

my_file <- read.csv('http://chart.yahoo.com/table.csv s=^gspc&a=0&b=01&c=1998&d=4&e=12&f=2013&g=d&q=q&y=0&z=^gspc&x=.csv')
于 2013-05-14T01:44:30.077 回答