Re: [R] detach

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu 13 Jul 2006 - 03:24:36 EST

On Wed, 12 Jul 2006, Martyn Plummer wrote:

> My guess is that even though the zoo namespace is unloaded. The S3
> method as.Date.numeric is still registered, and the name space will be
> reloaded whenever it is dispatched.
> > library(zoo)
> > loadedNamespaces()
> [1] "base" "graphics" "grDevices" "methods" "stats" "utils"
> [7] "zoo"
> > unloadNamespace("zoo")
> <environment: namespace:zoo>
> > loadedNamespaces() #Gone
> [1] "base" "graphics" "grDevices" "methods" "stats" "utils"
> > as.Date(1)
> [1] "1970-01-02"
> > loadedNamespaces() #Back again!
> [1] "base" "graphics" "grDevices" "methods" "stats" "utils"
> [7] "zoo"
>
> So the question is whether there is a way to unregister an S3 method, so
> that you can restore the method dispatching behaviour prior to the
> package being loaded. I don't know the answer, but I'm guessing it's no.

It is no. Namespaces don't work that way: one would have to keep a stack of past registered methods to be able to back out a registered method.

-- 
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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jul 13 03:31:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 13 Jul 2006 - 06:20:26 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.