I'm trying to give my colleagues a set of exercies concerning R basic intro (because i'm super junior on R...). I store the program in Github, and I want my colleagues to directly source it by using function source(). So I gave them several command lines:
source("https://raw.githubusercontent.com/elliott828/boulot-test/master/r.ex.R")
r.ex()
unfortunately the code only works on WINDOWS, error message poped up in OS X system (some colleagues use MAC):
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) : unsupported URL scheme
then I searched on StackOverflow and I found a solution for reading .csv from github: Read a CSV from github into R
then I edit a bit the command for OS X:
if(!"RCurl" %in% installed.packages()){install.packages("RCurl")}
library(RCurl)
ex <- getURL("https://raw.githubusercontent.com/elliott828/boulot-test/master/r.ex.R",
ssl.verifypeer=0L, followlocation=1L)
writeLines(ex, "temp.R")
source("temp.R")
r.ex()
It works well now on MAC.
but I'm still wondering if there is a more efficient way to read .R from Github directly on MAC? and why on MAC the link "https:....R" is an unsupported URL scheme?