How would I discover that + is a method for POSIXct? Applying methods() to POSIXt and POSIXct does not reveal it.> methods(class="POSIXt")[1] as.character.POSIXt cut.POSIXt diff.POSIXt [4] hist.POSIXt julian.POSIXt months.POSIXt [7] quarters.POSIXt seq.POSIXt str.POSIXt [10] weekdays.POSIXt> methods(class="POSIXct")[1] [.POSIXct [[.POSIXct [<-.POSIXct [4] all.equal.POSIXct as.data.frame.POSIXct c.POSIXct [7] format.POSIXct mean.POSIXct plot.POSIXct [10] print.POSIXct rep.POSIXct summary.POSIXct Applying methods() to "+" does give it but, in general, this would not be a feasible way to discover it since it would be tantamount to trying everything possible:> methods("+")[1] +.POSIXt Is there some other way?
On 28 Nov 2003 at 16:27, Gabor Grothendieck wrote: How would I discover that + is a method for POSIXct? Applying methods() to POSIXt and POSIXct does not reveal it. Reading ?POSIXct will tell you. Kjetil Halvorsen> methods(class="POSIXt")[1] as.character.POSIXt cut.POSIXt diff.POSIXt [4] hist.POSIXt julian.POSIXt months.POSIXt [7] quarters.POSIXt seq.POSIXt str.POSIXt [10] weekdays.POSIXt> methods(class="POSIXct")[1] [.POSIXct [[.POSIXct [<-.POSIXct [4] all.equal.POSIXct as.data.frame.POSIXct c.POSIXct [7] format.POSIXct mean.POSIXct plot.POSIXct [10] print.POSIXct rep.POSIXct summary.POSIXct Applying methods() to "+" does give it but, in general, this would not be a feasible way to discover it since it would be tantamount to trying everything possible:> methods("+")[1] +.POSIXt Is there some other way? ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Sure, but why are some methods found using methods("POSIXct") while other methods not found? It would be nice to have some reliable documentation-independent way to discover all the methods for a class. --- Date: Fri, 28 Nov 2003 23:17:45 -0400 From: <kjetil at entelnet.bo> To: <R-help at stat.math.ethz.ch>, <ggrothendieck at myway.com> Subject: Re: [R] Discovering methods On 28 Nov 2003 at 16:27, Gabor Grothendieck wrote: How would I discover that + is a method for POSIXct? Applying methods() to POSIXt and POSIXct does not reveal it. Reading ?POSIXct will tell you. Kjetil Halvorsen> methods(class="POSIXt")[1] as.character.POSIXt cut.POSIXt diff.POSIXt [4] hist.POSIXt julian.POSIXt months.POSIXt [7] quarters.POSIXt seq.POSIXt str.POSIXt [10] weekdays.POSIXt> methods(class="POSIXct")[1] [.POSIXct [[.POSIXct [<-.POSIXct [4] all.equal.POSIXct as.data.frame.POSIXct c.POSIXct [7] format.POSIXct mean.POSIXct plot.POSIXct [10] print.POSIXct rep.POSIXct summary.POSIXct Applying methods() to "+" does give it but, in general, this would not be a feasible way to discover it since it would be tantamount to trying everything possible:> methods("+")[1] +.POSIXt Is there some other way?
On Fri, 28 Nov 2003, Gabor Grothendieck wrote:> > > Sure, but why are some methods found using methods("POSIXct") > while other methods not found? > > It would be nice to have some reliable documentation-independent > way to discover all the methods for a class.Indeed it would, but that requires registration of methods using either the S4 approach or the functions for handling S3 methods in namespaces. Without this, it is simply not possible to decide, for example, whether t.test.formula is a method for t() or for t.test() or a separate function. -thomas
Thanks. I guess we have to be content to approximate this via: apropos("POSIXt$|POSIXct$") although this supposes we know that POSIXct inherits from POSIXt and its not clear that there is a reliable way to discover that for S3 classes. --- Date: Sun, 30 Nov 2003 13:10:52 -0800 (PST) From: Thomas Lumley <tlumley at u.washington.edu> To: Gabor Grothendieck <ggrothendieck at myway.com> Cc: <kjetil at entelnet.bo>, <R-help at stat.math.ethz.ch> Subject: Re: [R] Discovering methods On Fri, 28 Nov 2003, Gabor Grothendieck wrote:> > > Sure, but why are some methods found using methods("POSIXct") > while other methods not found? > > It would be nice to have some reliable documentation-independent > way to discover all the methods for a class.Indeed it would, but that requires registration of methods using either the S4 approach or the functions for handling S3 methods in namespaces. Without this, it is simply not possible to decide, for example, whether t.test.formula is a method for t() or for t.test() or a separate function. -thomas
On Sun, 30 Nov 2003, Thomas Lumley wrote:> On Fri, 28 Nov 2003, Gabor Grothendieck wrote: > > > Sure, but why are some methods found using methods("POSIXct") > > while other methods not found? > > > > It would be nice to have some reliable documentation-independent > > way to discover all the methods for a class. > > Indeed it would, but that requires registration of methods using either > the S4 approach or the functions for handling S3 methods in namespaces. > > Without this, it is simply not possible to decide, for example, whether > t.test.formula is a method for t() or for t.test() or a separate function.It also needs registration of generics. No one thought to list the members of the group generics (such as "+") as individual generics until recently, and methods() does try to find a corresponding generic to at least find out if t() and t.test() are generic functions. methods() is R-devel does a better job -- even that in R-patched does a better job now a couple of long-standing bugs in find() have been fixed. -- 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