簡體   English   中英

從遠程設備選擇 CRAN 鏡像

[英]selecting CRAN mirror from remote device

我正在遠程運行作業,並且運行它的集群沒有我需要的 R 包。 我嘗試使用以下方法安裝它:

if(!require(hglm)){install.packages("hglm");require(hglm)}

並意識到我需要選擇一個 CRAN 鏡像。 我嘗試添加:

selectCRANmirror()

到腳本,但收到錯誤信息,無法非交互選擇CRAN鏡像。

然后我嘗試添加:

selectCRANmirror(ind=72)

因為這是我將在本地計算機上用於將 CRAN 鏡像設置為 UK(St. Andrews) 的方法,但這會生成錯誤消息:

Error in chooseCRANmirror(ind = 72) : unused argument(s) (ind = 72)

我想知道是否有人可以解釋如何在遠程設備上選擇 CRAN 鏡像?

我修改了我的腳本以包含建議的行:

if(!require(hglm)){install.packages("hglm",repos="http://cran.us.r-project.org")

替換為“ http://star-www.st-andrews.ac.uk/cran ”(聖安德魯斯鏡像)並收到以下消息(我已經包含了前面的腳本以幫助闡明問題所在):

setwd("~/lustre2/s0784669")
load("df1QCMAF.RData")
.libPaths('~/RLibrary')
if(!require(GenABEL)){install.packages("GenABEL");require(GenABEL)}
#Loading required package: GenABEL
#Loading required package: MASS
#GenABEL v. 1.7-6 (May 16, 2013) loaded
if(!require(hglm)){install.packages("hglm",repos="http://star-www.st-andrews.ac.uk/cran");require(hglm)}
#Loading required package: hglm
#Installing package(s) into '/export/users/s0784669/RLibrary'
#(as 'lib' is unspecified)
#Warning: unable to access index for repository http://star-www.st-andrews.ac.uk/cran/src/contrib

我努力了:

library(RCurl)
url.exists("http://star-www.st-andrews.ac.uk/cran")

確定群集上的 Internet 訪問並收到以下消息:

library(RCurl);
#Loading required package: bitops
url.exists("star-www.st-andrews.ac.uk/cran")
#[1] FALSE 

建議不能上網。 那么我是否必須訪問源代碼? 這是可以訪問的嗎?

?install.packages

repos字符向量,要使用的存儲庫的基本 URL,例如,CRAN 鏡像的 URL,例如“ http://cran.us.r-project.org ”。

所以做一些類似install.packages("hglm", repos="http://cran.us.r-project.org")事情。 將 URL 插入到 St Andrews。

我有同樣的問題,然后我嘗試了這個並且它有效:

chooseCRANmirror(ind = 77)

將此代碼放在任何install.packages()語句之前,您可以運行整個 R 腳本並以非交互方式成功安裝包。 雖然已經 7 年了,但我希望這對你有用,對其他人也有用!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM