Message-ID: <504D86A9.6020108@gmail.com>
Date: 2012-09-10T06:20:25Z
From: Duncan Murdoch
Subject: Rscript installing packages
In-Reply-To: <CAF7Stsa+j9WzPFB-zQCx-AYihE4T0k60FkMf8yK=oS1ODNFQUw@mail.gmail.com>
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