user2170010
user2170010

Reputation: 185

how to load from github

I am following this tutorial: http://systematicinvestor.wordpress.com/2012/01/29/multiple-factor-model-fundamental-data/

When I run the first script I get a multitude of errors such as

Error in url("http://www.systematicportfolio.com/sit.gz", "rb") : cannot open the connection

Could anyone provide guidance on how to use this?

Upvotes: 0

Views: 1061

Answers (1)

A5C1D2H2I1M1N2O1R2T1
A5C1D2H2I1M1N2O1R2T1

Reputation: 193667

In the first few lines of the code, you see the following:

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

Follow that URL, and you will find alternative methods to load the "SIT". For me (as suggested by @RicardoSaporta) the one that popped out as most likely to work in a general manner (because of https, binary files, and so on) was the RCurl method. (Be sure you have RCurl installed first!)

###############################################################################
# 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)

Use that for the first few lines and you should be able to process the rest of the code.


Alternatively, manually download the file from https://github.com/systematicinvestor/SIT/raw/master/sit.gz and load it with:

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

and proceed from there.


Beyond that, the blog post you linked to doesn't mention a critical piece of information: what packages you need to have installed and loaded. You need to install and load "xts" and "quantmod" before running the rest of the script.

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

Upvotes: 3

Related Questions