简体   繁体   中英

R quandl : couldn't connect to host

I am begining to use Quandl facilities to import datasets to R with Quandl R API. It appears to be the easiest thing. However I have a problem. The below pasted snipet of code does not work (for me). It returns an error.

library(Quandl)

my_quandl_dtst <- Quandl("DOE/RBRTE")

Error in function (type, msg, asError = TRUE)  : couldn't connect to host 

What could be the cause of the problem?

I searched this site and found some solutions, also the one below, but it does not work for me.

set_config(use_proxy(url='your.proxy.url',port,username,password))

On the other hand, read.csv with url pasted from quandl website export dataset facility works:

my_quandl_dtst <- read.csv('http://www.quandl.com/api/v1/datasets/DOE/RBRTE.csv?', colClasses = c('Date' = 'Date'))

I would realy like to use the Quandl library, since using it would make my code cleaner. Therefore I would appreciate any help. Thanks in advance.

Ok, I found the solution, I had to set RCurlOptions, because the Quandl function uses getURL() to download data from url. But I had to use options() function as well. So:

options(RCurlOptions = list(proxy = "my.proxy", proxyport = my.proxyport.number))

head(quandldata <- Quandl("NSE/OIL"))

    Date  Open   High    Low   Last  Close Total Trade Quantity Turnover (Lacs)
1 2014-03-03 453.5 460.05 450.10 450.30 451.30                90347          410.08
2 2014-02-28 440.0 460.00 440.00 457.60 455.55               565074         2544.66
3 2014-02-26 446.2 450.95 440.00 440.65 440.60               179055          794.24
4 2014-02-25 445.1 451.75 445.10 446.60 447.20                86858          389.38
5 2014-02-24 443.0 449.50 443.00 446.50 446.30                81197          362.33
6 2014-02-21 447.9 448.65 442.95 445.50 446.80                95791          427.32

我猜您需要检查域quand1.com是否接受与RBRTE.csv文件的远程连接。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM