[R] detach

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jul 12 19:24:36 CEST 2006


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



More information about the R-help mailing list