Skip to content
Prev 28943 / 63424 Next

seeing an S4 method, not using it

Hi Thibaut --

The short answer seems to be that this is fixed in the devel 
implementation of S4 (at least, my effort at reproducing this was 
successful in 2.7 but not R version 2.8.0 Under development (unstable) 
(2008-05-22 r45762)).

I think it is like this

http://tolstoy.newcastle.edu.au/R/e2/devel/07/09/4469.html

My understanding of the problem is that when the object is read in the 
necessary package is 'load'ed but not 'attach'ed -- R knows about the 
class definition, etc, but methods and functions from the package are 
not on the search path, i.e., after reading your data object, the result 
of search() does not contain the package.

When you 'show' your object, S4 tries to find an appropriate method, but 
does not. So it uses the default, and makes a note that your object 
should be printed with that. After printing, showMethods('show') will 
indicate that your object has a 'show' method inherited from 'ANY'. 
Unfortunately, if you now load the package, nothing good happens -- the 
appropriate show method is available, but S4 thinks that it already 
knows a method for your object (the 'ANY' method) so does not find your 
version.

Confusing, isn't it?

Martin
Thibaut Jombart wrote: