[R] Discovering methods

Gabor Grothendieck ggrothendieck at myway.com
Fri Nov 28 22:27:06 CET 2003

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?

More information about the R-help mailing list