On Tue, May 18, 2010 at 22:38, William Dunlap <wdun...@tibco.com> wrote:
> > -----Original Message----- > > From: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-project.org] On Behalf Of Martin Maechler > > Sent: Tuesday, May 18, 2010 1:25 PM > > To: milton ruser > > Cc: r-h...@r-project.org > > Subject: Re: [R] avoiding reinstall already installed *package* > > > > On Tue, May 18, 2010 at 18:06, milton ruser > > <milton.ru...@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' > Well, both require() and library() pretty soon lead to an error if the package is not available... but I agree that you'd prefer to get the more helpful error message immediately rather than belatedly. If that's an issue, the typical use of require() would be if(require(...)) { ... ... } else { stop("..... not available; do this or that ") } but instead of stop(..) which can provide a context dependent, "customized" error message, you can also work around the absence of the package in other ways. a usePackage() function would typically use "best" of library() and require() , maybe not allowing usePackage(MASS) but requiring usePackage("MASS") but also working "logically" e.g. for mylme <- "lme4" usePackage(mylme) i.e. not allowing non-standard evaluation. 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 < > > > maech...@stat.math.ethz.ch> wrote: > > > > > >> { I've modified the subject; I can't stand it hitting square into > > >> my face ... } > > >> > > >> >>>>> "mr" == milton ruser <milton.ru...@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-h...@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-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel