From ripley at stats.ox.ac.uk  Thu Dec 18 09:01:40 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Dec 18 09:00:19 2003
Subject: [Rd] Reorganization of packages in the R distribution
In-Reply-To: <D7A3CFD7825BD6119B880002A58F06C20680AC2D@groexmb02.pfizer.com>
Message-ID: <Pine.LNX.4.44.0312172209590.27526-100000@gannet.stats>

The short answer is no: there is no supported way to override an R system 
function.  The only reason we can see to do that is to correct a bug, and 
we would prefer to get the buggy original changed ASAP.

It is much preferable for package authors to name variant versions
differently: if any 1 is allowed to masquerade, then N > 1 can do so too
and their versions will conflict.

However, if you wish to engage in this activity, the way you do it is
almost as good as any.  In these days of namespaces, something like

lowess.default <- stats::lowess

is needed, so

lowess.default <-
   if(R.version$major == 1 && R.version$minor < 9) base::lowess
   else stats::lowess

looks about right (since I suspect your code is not intended for R <
1.6.0).

Nevertheless, be aware that there is no guarantee that users will get your 
version because of the namespace scoping rules.


On Tue, 16 Dec 2003, Warnes, Gregory R wrote:

> 
> Ok, to take this thread in a slightly different direction.  In my 'gregmisc'
> package I redefine the R code 'lowess' function 
> by moving the existing 'lowess' to 'lowess.default' and making 'lowess' a
> generic. 
> 
> Is there a "proper" and "supported" way of accomplishing this task?
> 
> [Please ignore for the moment whether this is appropriate for the lowess
> function.  That is a separate discussion.]

-- 
Brian D. Ripley,                  ripley@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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] Reorganization of packages in the R distribution
Prof Brian Ripley