Re: [R] detach

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 13 Jul 2006 - 04:48:10 EST

Looks like one can do the following. Don't know if it would cause problems elsewhere. Note that after removing as.Date.numeric from the S3 Methods Table as.Date.numeric was no longer dispatched.

> as.Date(1)

Error in as.Date.default(1) : do not know how to convert '1' to class "Date"
> library(zoo)
> as.Date(1)

[1] "1970-01-02"
> unloadNamespace("zoo")

<environment: namespace:zoo>
> rm(as.Date.numeric, envir = .__S3MethodsTable__.)
> as.Date(1)

Error in as.Date.default(1) : do not know how to convert '1' to class "Date"

On 7/12/06, Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:
> 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 04:54:07 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:40 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.