read.csv(“http://ichart.finance.yahoo.com/table.csv?s=SPY”)不工作

问题描述:

我一直在使用下面的命令很长一段时间没有问题:read.csv(“http://ichart.finance.yahoo.com/table.csv?s=SPY”)不工作

spy <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=SPY") 

但在过去的几天就开始抛出以下错误:

Warning messages:

1: In file(file, "rt") : "internal" method cannot handle https redirection to: ' https://ichart.finance.yahoo.com/table.csv?s=SPY '

2: In file(file, "rt") : "internal" method failed, so trying "libcurl"

我已经更新了我RStudio,R和所有的软件包,以最先进的最新版本为今天的。有人可以帮我解决这个问题吗?

在此先感谢!

+0

只是改变URL从* HTTP *为* HTTPS *。 – Parfait

+0

谢谢Parfait! – ilearncoding

解决方法是错误消息就在那里:使用HTTPS不是http:

R> spy <- read.csv("https://ichart.finance.yahoo.com/table.csv?s=SPY") 
R> head(spy) 
     Date Open High Low Close Volume Adj.Close 
1 2017-04-19 234.52 234.95 233.18 233.44 66861500 233.44 
2 2017-04-18 233.72 234.49 233.08 233.87 80188300 233.87 
3 2017-04-17 233.11 234.57 232.88 234.57 63559500 234.57 
4 2017-04-13 233.64 234.49 232.51 232.51 83019800 232.51 
5 2017-04-12 234.74 234.96 233.77 234.03 76322100 234.03 
6 2017-04-11 234.90 235.18 233.34 235.06 85727700 235.06 
R> 
+0

这样做。非常感谢! – ilearncoding

+0

没问题 - 几个软件包也在本周做出了改变。 –

+0

在修复程序进入时更新软件包。 –

如果您使用的是功能getReturnsstockPortfolio包,请使用修改后的getReturns功能以下链接:

https://gist.github.com/Maiae/46a058243819ae0973fd38708a32fc31

它基本上取代HTTP:// w ^第i个https://开头

雅虎采空服务,如果您想与小数据集下载CSV从这里运行和使用

https://github.com/datasets/s-and-p-500-companies