[R] avoiding reinstall already installed *package*

Henrik Bengtsson hb at stat.berkeley.edu
Wed May 19 07:54:22 CEST 2010


On Wed, May 19, 2010 at 7:20 AM, milton ruser <milton.ruser at gmail.com> wrote:
> *but* going back to my question, is not true
> that already installed packages will not be
> reinstaled. I ran:
>
> install.packages(c("ggplot2"),dependencies=T)
> install.packages(c("mgcv","bbmle","akima","drc","sensitivity","tgp"),dependencies=T)
>
> and several packages installed during the first install.packages
> were reinstalled on the second install.packages.

I guess your question is, if I do

install.packages("fortunes");
install.packages("fortunes");

will the 'fortunes' package be installed twice?  Answer, yes.

It would probably not be too hard to add a 'force' argument so that:

# Install package first time
install.packages("fortunes");

# If package is already installed, skip it.
install.packages("fortunes", force=FALSE);

# If package is already installed, install it again.
install.packages("fortunes", force=TRUE);

If force=FALSE is the default, then

install.packages("fortunes");
install.packages("fortunes");

would install only once.  I can also imagine force="ask" an more.
Maybe there are better names for the argument, e.g. onExist=c("skip",
"install", "ask").

/Henrik

>
> cheers
>
> milton
>
> On Tue, May 18, 2010 at 5:38 PM, William Dunlap <wdunlap at tibco.com> wrote:
>
>> > -----Original Message-----
>> > From: r-help-bounces at r-project.org
>> > [mailto:r-help-bounces at r-project.org] On Behalf Of Martin Maechler
>> > Sent: Tuesday, May 18, 2010 1:25 PM
>> > To: milton ruser
>> > Cc: r-help at r-project.org
>> > Subject: Re: [R] avoiding reinstall already installed *package*
>> >
>> > On Tue, May 18, 2010 at 18:06, milton ruser
>> > <milton.ruser at gmail.com> wrote:
>> >
>> > > Hi Martin,
>> > >
>> > > thanks for your reply, and very thanks for your kind tips
>> > about "package"
>> > > and "library"
>> > > So, I was trying to understand *why* we load packages using
>> > library().
>> > >
>> >
>> > I've started to use and suggest using   require(.) instead
>> > {as my efforts to introduce  use() or usePackage() *and* deprecating
>> >  library()  where met with strong opposition}
>>
>> I hate to get into arguments over function names, but
>> I would have thought that require("pkg") would throw
>> an error if the required pkg was not available.  It seems
>> like require() can be used when pkg is not really required
>> but library("pkg") is easiest when pkg is required to
>> continue:
>>
>>  > { require("noSuchPackage"); functionFromNoSuchPackage() }
>>  Loading required package: noSuchPackage
>>  Error: could not find function "functionFromNoSuchPackage"
>>  In addition: Warning message:
>>  In library(package, lib.loc = lib.loc, character.only = TRUE,
>> logical.return = TRUE,  :
>>    there is no package called 'noSuchPackage'
>>  > { library("noSuchPackage"); functionFromNoSuchPackage() }
>>  Error in library("noSuchPackage") :
>>    there is no package called 'noSuchPackage'
>>
>> Bill Dunlap
>> Spotfire, TIBCO Software
>> wdunlap tibco.com
>>
>> >
>> >
>> > > I suggest that developers killl the problem on its root,
>> > deleting library
>> > > function :-)
>> > > Good to know already installed packages will not be reinstalled.
>> > >
>> > > cheers
>> > >
>> > > milton
>> > >
>> > > On Tue, May 18, 2010 at 12:49 PM, Martin Maechler <
>> > > maechler at stat.math.ethz.ch> wrote:
>> > >
>> > >> { I've modified the subject; I can't stand it hitting square into
>> > >>  my face ... }
>> > >>
>> > >> >>>>> "mr" == milton ruser <milton.ruser at gmail.com>
>> > >> >>>>>     on Tue, 18 May 2010 12:36:23 -0300 writes:
>> > >>
>> > >>    mr> Dear R-experts,
>> > >>    mr> I am installing new libraries using
>> > >>    mr> install.packages("ggplot2",dependencies=T).
>> > >>    mr> But I perceive that many dependencies are already
>> > installed. As I
>> > >> am using
>> > >>    mr> a low-band internet, how can avoid reinstall
>> > installed libraries?
>> > >>
>> > >> There's no problem with installed libraries, as ...
>> > >> they DO NOT EXIST.
>> > >>
>> > >> These are *PACKAGES* !
>> > >> Why do you think are you talking about the function
>> > >>
>> > >>  install.packages()  ????
>> > >>         ^^^^^^^^
>> > >>
>> > >> ---
>> > >> To answer the question you did want to ask:
>> > >>
>> > >> Do not be afraid:  Depedencies are only installed when needed,
>> > >> i.e., no package will be downloaded and installed if it already
>> > >> is there.
>> > >>
>> > >> Martin Maechler, ETH Zurich
>> > >>
>> > >>    mr> cheers
>> > >>
>> > >>    mr> milton
>> > >>
>> > >>    mr> [[alternative HTML version deleted]]
>> > >>        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> > >> (another thing you should learn to avoid, please)
>> > >>
>> > >>
>> > >
>> >
>> >       [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list