[R] Setting two default CRAN servers under Windows/RStudio

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jun 19 15:31:38 CEST 2015


On 19/06/2015 8:14 AM, Sigbert Klinke wrote:
> Hi,
> 
> we are running in our network a non-public CRAN mirror. I got it working
> with the entry in "Rprofile.site"
> 
> local({r <- getOption("repos")
>        r["CRAN"] <- "http://local.cran.server"
>        options(repos=r)
> })
> 
> In case that our CRAN mirror does not work we want to send the R/RStudio
> users to a public server. I tried
> 
> 1.
> local({r <- getOption("repos")
>        r["CRAN"] <- c("CRAN"="http://local.cran.server", r)
>        options(repos=r)
> })
> 
> -> install.packages offered the list of public mirrors
> 
> 2.
> local({r <- getOption("repos")
>        r["CRAN"] <- c(r, "CRAN"="http://local.cran.server")
>        options(repos=r)
> })
> 
> -> packages are taken from cran.rstudio.com
> 
> 3.
> local({r <- getOption("repos")
>        r["CRAN"] <- c(r["CRAN"], "CRAN"="http://local.cran.server",
> r["CRANextra"])
>        options(repos=r)
> })
> 
> -> packages are taken from cran.rstudio.com
> 
> None of the solutions worked under RStudio, the packages are always
> installed from the public servers. Any ideas?

Your options seem to be trying to put a length two vector into a single
entry.  Just create a vector like

r <- c(localCRAN = "http://local.cran.server", r)

and you'll get a length two vector instead.

Duncan Murdoch

Duncan Murdoch



More information about the R-help mailing list