Re: [Rd] "Incompatible methods" for overloaded operator

From: Renaud Gaujoux <>
Date: Thu, 21 Jun 2012 13:22:01 +0200


I may be mistaken here but a possible interpretation of:

"If a method is found for just one argument or the same method is found for both, it is used."

could be that "the same method" here does not mean identical in term of object/content (as identical tests), but means that the two arguments resolve to the same method definition, i.e. a single common method exists for both arguments. This would happen is if a single method is defined for a common parent class. Try:

`+.C` <- function(x1, x2){

     message("Running custom + function") }

x <- structure(1, class=c('A', 'C'))
y <- structure(1, class=c('B', 'C'))

x + y

Another work around would be to define only one method for class 'a' and do the dispatch to `plus.b` in there (might even be able to call it
`+.b` if not exported).

Might be a good suggestion to add a test in UseMethod to check is the methods are in fact identical. But there might be undesired side effects: two identical methods in different environment that behave differently depending on the state of the environment? By the way any way of seeing any code of primitive function or are these pure C functions, which need to be searched for in R source code?


Renaud Gaujoux
Computational Biology - University of Cape Town
South Africa

______________________________________________ mailing list
Received on Thu 21 Jun 2012 - 11:24:33 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Jun 2012 - 12:10:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive