我有一个带有相互依赖的R脚本的GitHub项目,其中一些是我想要的。我跑的时候
source_https <- function(url) {
require(RCurl)
sapply(c(url), function(u) {
eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
})
}
source_https("https://path_to_repository/one_of_the_scripts.R")
我自然会收到一条错误消息:
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file 'another_script.R': No such file or directory
我有什么办法可以整个项目的来源吗?
答案 0 :(得分:0)
我的解决方案如下:
source_https <- function(url) {
require(RCurl)
sapply(c(url), function(u) {
getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))
})
}
source_https("https://path_to_repository/one_of_the_scripts.R")
我没有使用eval(解析(...))
看到qhy答案 1 :(得分:0)
将其设为R包,如roland所示,解决了这个问题。