[R] Confusing difference in S4 summary method dispatch within an S3 summary

Christopher N. Lawrence c.n.lawrence at gmail.com
Fri Dec 1 23:34:24 CET 2006


I'm trying to track down a problem I'm having in the Zelig package and
have stumbled across a very odd difference in the method dispatch for
a derived S4 class.

Specifically, I have an object of class ZeligS4vglm, which is a
subclass of vglm and vlm respectively (these are from the VGAM
package).

summary() at the command line prompt of this object calls
summary.vglm, which is what I expect to happen.

However, when summary() is called on this object from within another
summary() (summary.MI in Zelig... MI is an S3 class wrapping a number
of ZeligS4vglm objects in this case), it appears to be using the
generic summary() method and ignoring the summary methods defined for
the object:

Browse[1]> summary(object[[1]])
     Length Class       Mode
[1,] 1      ZeligS4vglm S4

I assume this has something to do with protecting the programmer from
infinite recursion into summary() - i.e. so summary.object <-
function(x) { summary(x) } doesn't blow up the stack - but is there a
workaround?


Chris
-- 
Christopher N. Lawrence <clawren6 at slu.edu>
Assistant Professor of Political Science (non-tenure-track)
Saint Louis University
109 Fitzgerald Hall
3500 Lindell Boulevard
St. Louis, Missouri 63103-1021

Website: http://www.cnlawrence.com/




More information about the R-help mailing list