2014-03-03 139 views
2

我開始使用Quandl工具通過Quandl R API將數據集導入到R中。這似乎是最容易的事情。但是我有一個問題。下面粘貼snipet代碼不起作用(對我來說)。它返回一個錯誤。R quandl:無法連接到主機

library(Quandl) 

my_quandl_dtst <- Quandl("DOE/RBRTE") 

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

什麼可能是問題的原因?

我搜索了這個網站,發現了一些解決方案,也是下面的一個,但它不適用於我。

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

在另一方面,read.csv與URL從quandl網站出口數據集設施工程粘貼:

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

我會真的喜歡用Quandl庫,因爲使用它會讓我的代碼清潔器。因此,我將不勝感激任何幫助。提前致謝。

回答

0

我想你需要檢查域quand1.com是否接受遠程連接到RBRTE.csv文件。

3

好的,我找到了解決方案,我不得不設置RCurlOptions,因爲Quandl函數使用getURL()從url下載數據。但我不得不使用options()函數。所以:

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