Re: [R] showMethods doubt

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Fri 03 Jun 2005 - 00:20:33 EST

Ernesto Jardim wrote:
> Hi,
>
> I'm developing in S4 and I wanted to see the methods for a specific
> class using showMethods but I didn't succed. Can someone help ? See the
> example below.
>
> setClass("myclass",
> representation(
> name ="character"
> )
> )
>
> setGeneric("mymeth", function(obj, ...){
> standardGeneric("mymeth")
> }
> )
>
> setMethod("mymeth", signature("myclass"), function(obj){
> print(paste("Hi,", obj@name, "and I don't know what to do with
> showMethods !"))
> }
> )
>
> Now if you do:
>

>> myobj <- new("myclass", name="my name is joe")
>> mymeth(myobj)

> [1] "Hi, my name is joe and I don't know what to do with showMethods !"
>
> So the method is working, let's use showMethods:
>
>> showMethods(classes="myclass")

>
> Function "addNextMethod":
> <Empty Methods List>
>
> Function "body<-":
> <Empty Methods List>
>
> Function "coerce":
> <Empty Methods List>
>
> Function "initialize":
> .Object = "myclass"
> (inherited from .Object = "ANY")
>
> Function "loadMethod":
> <Empty Methods List>
>
> Function "show":
> object = "myclass"
> (inherited from object = "ANY")
> NULL
>
> mymeth does not show on that list, why ?

Try

showMethods(classes = "myclass", where = .GlobalEnv)

I believe the convention is that unless you give showMethods a generic function as argument `f' it will look for the generics in "package:methods".



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 Fri Jun 03 00:27:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:21 EST