[R] Rscript installing packages

Duncan Murdoch murdoch.duncan at gmail.com
Mon Sep 10 08:20:25 CEST 2012


On 12-09-10 2:03 AM, Diviya Smith wrote:
> Hi there
>
> I have an Rscript and I am looking for a way to install a package
> non-interactively. In Rscript {Utils}, I saw an example which does
> something like this, however this does not seem to work for my particular
> example. I am trying to install the following package in an Rscript
> (without switching to interactive mode).
>
> res <- try(install.packages("DEoptim"))
>
> if(inherits(res, "try-error")) q(status=1) else q()
>
>
> Error:
>
> Installing package(s) into ‘/home/xx/R/x86_64-pc-linux-gnu-library/2.13’
>
> (as ‘lib’ is unspecified)
>
> Error in contrib.url(repos, type) :
>
>    trying to use CRAN without setting a mirror
>
>
> Any idea how I can fix this or specify "lib"? Any help would be most
> appreciated.
>

You need to set a CRAN mirror.  options("repos") should not contain the 
dummy value "@CRAN@", you should put in the URL of your mirror.

Duncan Murdoch




More information about the R-help mailing list