[R] Follow-up: pos= in library and require

Frank E Harrell Jr fharrell at virginia.edu
Sat Apr 13 20:59:36 CEST 2002

On Sat, 13 Apr 2002 14:01:01 +0100 (BST)
ripley at stats.ox.ac.uk wrote:

> On Sat, 13 Apr 2002, Frank E Harrell Jr wrote:
> > Unfortunately I found that adding pos= in the attach( ) inside library( ) results in a corruption of the search list.  Packages will be attached in the desired position but the system then can't find any objects in that position.  I would really appreciate R correctly implementing pos= in library( ) and require( ).
> As you know (I hope) R 1.5.0 is currently in feature freeze.
> We've had a request to do this before, and we will look into it for 1.6.x.
> One issue that occurred to me was what one should do about calls to
> library() or require() from the .First.lib (or on loading the code) of a
> package if a pos argument is allowed.  Are the dependent packages supposed
> to displace the first package or not?  What if the dependent packages are
> themselves given a pos= argument (as I think you wanted)?

That's a good question.  But there needs to be some kind of simple way to make require or library attach at the end of the search list instead of position 2, i.e., to get S-Plus's behavior.

A safe approach for now is to instruct users to put library() commands in .Rprofile for dependent packages that we do not wish to override others.  They will be put high in the search path when R starts, and then will move down the list.  

> I prefer to do tricky things early in the release cycle, to allow plenty
> of experience with them.  Time has shown that few changes are
> transparently simple.

Yes, that makes complete sense.  Thanks -Frank

> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272860 (secr)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list