2
我嘗試使用github創建的源代碼plugin-draw.R如何使用這個blugin?如何從github使用R腳本?
我嘗試使用github創建的源代碼plugin-draw.R如何使用這個blugin?如何從github使用R腳本?
您可以使用R-Bloggers提供的解決方案:
source_github <- function(u) {
# load package
require(RCurl)
# read script lines from website
script <- getURL(u, ssl.verifypeer = FALSE)
# parase lines and evaluate in the global environment
eval(parse(text = script))
}
source("https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/bingSearchXScraper/bingSearchXScraper.R")
對於功能在全球環境(我猜你會喜歡這個解決方案)進行評估,你可以使用:
source_https <- function(u, unlink.tmp.certs = FALSE) {
# load package
require(RCurl)
# read script lines from website using a security certificate
if(!file.exists("cacert.pem")) download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile = "cacert.pem")
script <- getURL(u, followlocation = TRUE, cainfo = "cacert.pem")
if(unlink.tmp.certs) unlink("cacert.pem")
# parase lines and evealuate in the global environement
eval(parse(text = script), envir= .GlobalEnv)
}
source_https("https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/bingSearchXScraper/bingSearchXScraper.R")
source_https("https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/htmlToText/htmlToText.R", unlink.tmp.certs = TRUE)
如Tony Breyal在the original article提到,this discussion on SO也應該被記入,因爲它與討論的問題有關。