[R] S4 methods: unable to find an inherited method

Seth Falcon sfalcon at fhcrc.org
Wed Aug 8 21:03:08 CEST 2007

Hi Paul,

"H. Paul Benton" <hpbenton at scripps.edu> writes:
>     I consider myself pretty new to the whole OO based programming so
> I'm sorry if I'm doing something stupid.

These sorts of questions might be better sent to the R-devel list...

>> xml<-read.metlin(url)
> Error in function (classes, fdef, mtable)  :
>         unable to find an inherited method for function "read.metlin",
> for signature "url"

So the error message is telling you that it can't find a method for
the read.metlin generic that matches the class of the xml argument you
passed in.

You defined:

> setMethod("read.metlin", "xcmsRaw", function(xml) {
> #Parsing the METLIN XML File
>     reading<-readLines(xml)
> #    do rest of script
> })

So there is a method for read.metlin when the xml argument is an
xcmsRaw object.  As you show, you passed in an object with class

>> url
>                                        description
> "http://metlin.scripps.edu/download/MSMS_test.XML"
>                                              class
>                                              "url"

> Any help as to why I'm getting the inherited method error would be
> great.

You either need to add a method specialized on the url class (warning,
url is not an S4 class, there will be tricks required).  Or you need
to pass in an xcmsRaw object.


+ seth

Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
BioC: http://bioconductor.org/
Blog: http://userprimary.net/user/

More information about the R-help mailing list