On Tue, 2005-06-07 at 13:49 -0700, Berton Gunter wrote: > > Second, in my experiments I couldn't get setReplacementMethod to work: > > > > "bumpIndex<-" <- function(pm, value) { > > [EMAIL PROTECTED] <- [EMAIL PROTECTED](value) > > pm > > } > > > > # I get an error without the next function definition > > bumpIndex <- function(pm) [EMAIL PROTECTED] > > > > setReplaceMethod("bumpIndex", > > signature=signature(pm="CompletePathMaker", > > value="numeric"), bumpIndex) > > ... > > > When I try to load this, I get > > arguments in definition changed from (spec) to (object) > > arguments in definition changed from (self) to (object) > > arguments in definition changed from (self) to (object) > > Creating a new generic function for 'bumpIndex<-' in '.GlobalEnv' > > Error in conformMethod(signature, mnames, fnames, f) : > > In method for function "bumpIndex<-": formal arguments > > omitted in the > > method definition cannot be in the signature (value = "numeric") > > With some help from Bert, partly offlist, here's a working version: setReplaceMethod("bumpIndex", signature=signature(pm="CompletePathMaker", value="numeric"), function(pm, value) { [EMAIL PROTECTED] <- [EMAIL PROTECTED](value) pm }) At least 2 problems were caused by my original, final argument of bumpIndex to setReplaceMethod: 1) This looked for the function bumpIndex, not bumpIndex<-. That's why I had to define the bumpIndex function. With the above change, it is no longer necessary to define bumpIndex. I needed to point it to bumpIndex<-. I've been unable to find how to quote that properly.
2) The bumpIndex function doesn't have the right arguments. By the way, the use of "value" as the name for the final argument to the assignment function is mandatory. The info about value, as well as an extensive discussion of issues with mutating objects, appear in this 2003 tutorial by Gentleman: http://www.stat.auckland.ac.nz/S-Workshop/Gentleman/S4Objects.pdf (thanks to Bert for the pointer). Ross ______________________________________________ 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