[R] Object problems with Generic and rematchDefinition

From: H. Paul Benton <hpbenton_at_scripps.edu>
Date: Mon 02 Apr 2007 - 17:43:14 GMT

Hello all,

    Let me try this again with some code.

I am trying to make a new object and it's not working. I get :

Error in rematchDefinition(definition, fdef, mnames, fnames, signature) :

        methods can add arguments to the generic only if '...' is an argument to the generic

as my error. I have included my code. It is from the xcms package. Any help would be great even if it's just telling me what the error means. I know that if I make "searchM" a normal function that it works but I would really like a method.



require(methods) || stop("Couldn't load package methods")

setClass("xcmsRaw", representation(env = "environment", tic = "numeric",

                                   scantime = "numeric", scanindex =

profmethod = "character", profparam =
mzrange = "numeric", gradient =
msmsinfo = "matrix",MSMSmz= "vector", MSMSpreMZ = "vector", MSMSint = "vector", MSMSrt = "vector", MSMSpreZ =
MSMScount= "vector"), prototype(env = new.env(parent=.GlobalEnv), tic = numeric(0), scantime = numeric(0), scanindex = integer(0), profmethod = "bin", profparam = list(), mzrange = numeric(0), gradient = matrix(nrow=0, ncol=0), msmsinfo = matrix(nrow=0, ncol=0), MSMSmz= vector(), MSMSpreMZ = vector(), MSMSint = vector(), MSMSrt = vector(), MSMSpreZ = vector(), MSMScount= vector() ))

if ( !isGeneric("searchM") )

    setGeneric("searchM", function(object, ...) standardGeneric("searchM"))

setMethod("searchMetlin", "xcmsRaw", function(object, cost=5, ppm=10) {

    metlinfile<-url("http://") # need to add URL     met.xml<-read.metlin(metlinfile)
    values<-matrix(nrow=length(Pcount), ncol= 6)     colnames(values)<-c("Name", "Distance", "precursor MZ", "precursor Z", "rt", "MS/MS peaks")

    for(i in length(Pcount)){

    decide<-decideBest(met.xml, MSMSpeaks, cost, ppm)     if(decide$levenshtein<5){
        temp.values<-c(met.xml[decide$indexNum,1], decide$levenshtein,
preMZ, preZ,rtMSpeaks,
            paste(MSMSpeaks, collapse=":"))
    } #else cat(".") ?
    write.csv(values, file="xcms.tsv", col.names=NA, sep="\t")    


Research Technician
Mass Spectrometry
   o The
o Scripps
   o Research
o Institute

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Apr 03 03:47:49 2007

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 Mon 02 Apr 2007 - 18:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.