2013-03-26 40 views
0

加載我下面這個教程: http://systematicinvestor.wordpress.com/2012/01/29/multiple-factor-model-fundamental-data/如何從GitHub

當我運行一個腳本,我得到錯誤的多種作用,例如

錯誤的URL(「http://www.systematicportfolio.com/sit.gz」,‘RB’) : 無法打開連接

任何人都可以提供有關如何使用此指導?

+0

更適合superuser.com? – Arun 2013-03-26 16:24:54

+0

嘗試使用'RCurl'確保R可以訪問位置 – 2013-03-26 16:26:48

回答

3

在代碼的前幾行,你看到以下內容:

############################################################################### 
# Load Systematic Investor Toolbox (SIT) 
# http://systematicinvestor.wordpress.com/systematic-investor-toolbox/ 
############################################################################### 

按照該URL,你會發現可供選擇的方法來加載「坐」。對我來說(正如@RicardoSaporta所建議的那樣),最有可能以一般方式工作(因爲https,二進制文件等)的方法就是RCurl方法。 (請確保您有第一次安裝RCurl!)

############################################################################### 
# Load Systematic Investor Toolbox (SIT): Requires RCurl package 
############################################################################### 
require(RCurl) 
sit = getURLContent('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', binary=TRUE, followlocation = TRUE, ssl.verifypeer = FALSE) 
    con = gzcon(rawConnection(sit, 'rb')) 
    source(con) 
close(con) 

使用,對於前幾行,你應該能夠處理的代碼的其餘部分。


也可以手動從https://github.com/systematicinvestor/SIT/raw/master/sit.gz下載文件,並加載它:

con = gzcon(file('path/to/sit.gz', 'rb')) ## Replace with actual path 
    source(con) 
close(con) 

,並從那裏繼續。


除此之外,您鏈接到的博客文章沒有提及關鍵信息:您需要安裝和加載哪些軟件包。在運行腳本的其餘部分之前,您需要安裝並加載「xts」和「quantmod」。

install.packages("xts") 
install.packages("quantmod") 
library(xts) 
library(quantmod) 
+0

Thankyou Ananda這非常有幫助! – user2170010 2013-03-26 16:49:37

+0

是的,我剛剛遇到這個問題與xts ...我如何運行這個庫? – user2170010 2013-03-26 16:52:15