Skip to content

contrib.url in non-interactive mode

3 messages · Renaud Gaujoux, Brian Ripley, Dirk Eddelbuettel

#
On 14/02/2014 10:03, Renaud Gaujoux wrote:
You seem to be talking about installing from CRAN.  The intention is 
indeed that in non-interactive use you have to select the repositories 
you want to use.  See ?setRepositories and its links.

It is up to you to set a default mirror: we have little idea where you 
live (and it may not be where your email address suggests).  Geolocation 
of mirrors had been mooted but not implemented (and in a corporate 
setting is not 100% reliable).  The whole point of mirrors is to spread 
the load: without them there would be no CRAN as the main host would not 
allow the traffic.

This would have been appropriate for R-help, if it would not have been 
answered by doing the homework required by the posting guide (which also 
requires no HTML ...).

  
    
#
Renaud,

The script below has been in use for about as long as littler existed, and
also ships with it. I use it, and its sibbling 'update.r' all the time. Doing
this at the command-line frees the R prompt during compilations too...

As Barry suggests, the RStudio-provided CDN is not a bad choice either as a
repo. 

Dirk

edd at max:~$ cat bin/install.r 
#!/usr/bin/env r
#
# a simple example to install one or more packages

if (is.null(argv) | length(argv)<1) {

  cat("Usage: installr.r pkg1 [pkg2 pkg3 ...]\n")
  q()

}

## adjust as necessary, see help('download.packages')
#repos <- "http://cran.us.r-project.org"
repos <- "http://cran.r-project.org"

## this makes sense on Debian where no packages touch /usr/local
lib.loc <- "/usr/local/lib/R/site-library"

install.packages(argv, lib.loc, repos)
edd at max:~$