[Rd] Overloading S4 methods

From: Iago Mosqueira <iago.mosqueira_at_gmail.com>
Date: Wed, 01 Jun 2011 13:39:26 +0200

Dear all,

I am experiencing some problems with S4 method overloading. I have defined a generic for graphics:plot, using

setGeneric("plot", useAsDefault = plot)

and with

importFrom('graphics', 'plot') and

exportMethods('plot') in the NAMESPACE file of pkg A.

I then proceed to define a method for signature c('myS4class', 'missing'). This works as expected: selectMethod('plot', c('myS4class', 'missing')) returns the newly defined method, and the method gets called when invoked.

Another pkg, B, wishes to overload this and redefines the method for the same signature. A method is defined for c('myS4class', 'missing'), and exported on the NAMESPACE. The new method is shown by selectMethod() after pkg B has been loaded, but a call to


comes up with the result of running the first method, from pkg A. I have tried importing 'plot' in B's NAMESPACE from both graphics or A, but the end result is the same.

Package B does the same thing for a method created by pkg A, myMethod, and that works fine.

Any pointers or where this might be going wrong? How is it that a different method than the one shown by selectMethod() is being run? Something to do with the 'missing' part of the signature?

Many thanks,

Iago Mosqueira

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 01 Jun 2011 - 11:41:34 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 Mon 06 Jun 2011 - 11:50:15 GMT.

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

list of date sections of archive