[Rd] S4 methods for rbind()

Robin Hankin rksh1 at cam.ac.uk
Tue Oct 26 12:53:49 CEST 2010


I am trying to write an S4 method for rbind(). I have a class of objects
called 'mdm', and I want to be able to rbind() them to one another.

I do not want the method for rbind() to coerce anything to an mdm object.
I want rbind(x1,x2,x1,x2) to work as expected [ie rbind() should take any
number of arguments].

This is what I have so far:

setGeneric(".rbind_pair", function(x,y){standardGeneric(".rbind_pair")})
setMethod(".rbind_pair", c("mdm", "mdm"), function(x,y){.mdm.cPair(x,y)})
setMethod(".rbind_pair", c("mdm", "ANY"),
setMethod(".rbind_pair", c("ANY", "mdm"),
setMethod(".rbind_pair", c("ANY", "ANY"),

".mdm_rbind_error" <- function(x,y){
stop("an mdm object may only be rbinded to another mdm object")

".mdm.rbind_pair" <- function(x,y){
mdm(rbind(xold(x),xold(y)),c(types(x),types(y))) # this is the "meat" of
the rbind functionality

setMethod("rbind", signature="mdm", function(x, ...) {
.mdm_rbind_pair(x, Recall(...))


LE223:~/packages% sudo R CMD INSTALL ./multivator
Creating a new generic function for "tail" in "multivator"
Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
in method for ‘rbind’ with signature ‘deparse.level="mdm"’: formal
arguments (... = "mdm", deparse.level = "mdm") omitted in the method
definition cannot be in the signature
Error : unable to load R code in package 'multivator'
ERROR: lazy loading failed for package ‘multivator’
* removing ‘/usr/local/lib64/R/library/multivator’
* restoring previous ‘/usr/local/lib64/R/library/multivator’

I can't understand what the error message is trying to say.

Can anyone advise on a fix for this?

Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP

More information about the R-devel mailing list