问题
I am running jobs remotely, and the cluster I am running it on does not have the R package I require. I have tried to install it using:
if(!require(hglm)){install.packages("hglm");require(hglm)}
and realise that I am required to select a CRAN mirror. I tried adding:
selectCRANmirror()
to the script, but received the error message, cannot select CRAN mirror non-interactively.
I then tried adding:
selectCRANmirror(ind=72)
as this is what I would use on my local computer to set the CRAN mirror to UK(St. Andrews), but this generates the error message:
Error in chooseCRANmirror(ind = 72) : unused argument(s) (ind = 72)
I was wondering if anyone could explain how to select the CRAN mirror on a remote device?
I amended my script to include the line suggested:
if(!require(hglm)){install.packages("hglm",repos="http://cran.us.r-project.org")
replacing with "http://star-www.st-andrews.ac.uk/cran" (St. Andrews mirror) and received the following message (I have included preceding scripts to help illuminate where the problem lies):
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
I have tried:
library(RCurl)
url.exists("http://star-www.st-andrews.ac.uk/cran")
to ascertain internet access on the cluster and received the following message:
library(RCurl);
#Loading required package: bitops
url.exists("star-www.st-andrews.ac.uk/cran")
#[1] FALSE
Suggesting no internet access. So would I have to access source code? And is this accessible?
回答1:
Per ?install.packages
:
repos
character vector, the base URL(s) of the repositories to use, e.g., the URL of a CRAN mirror such as "http://cran.us.r-project.org".
So do something like install.packages("hglm", repos="http://cran.us.r-project.org")
. Insert the url to St Andrews instead.
来源:https://stackoverflow.com/questions/17924447/selecting-cran-mirror-from-remote-device