From: Ross Boylan <ross_at_biostat.ucsf.edu>

Date: Wed 08 Jun 2005 - 10:44:18 EST

> > 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",

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.

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 Wed Jun 08 10:48:07 2005

Date: Wed 08 Jun 2005 - 10:44:18 EST

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) {
**> > pm@i <- pm@i+as.integer(value)
**> > pm
**> > }
**> >
**> > # I get an error without the next function definition
**> > bumpIndex <- function(pm) pm@i
**> >
**> > setReplaceMethod("bumpIndex",
**> > signature=signature(pm="CompletePathMaker",
**> > value="numeric"), bumpIndex)
**> >
*

...

>

> > When I try to load this, I get

With some help from Bert, partly offlist, here's a working version: setReplaceMethod("bumpIndex",

signature=signature(pm="CompletePathMaker", value="numeric"), function(pm, value) { pm@i <- pm@i+as.integer(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 Received on Wed Jun 08 10:48:07 2005

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