[R] advice on semi-serious attempt to extend summary

From: ivo welch <ivowel_at_gmail.com>
Date: Mon 01 Jan 2007 - 21:03:50 GMT

Dear R wizards:

I am trying (finally) to build a function that might be useful to others. In particular, I want to create a summary.lme (extended lm) method that [a] adds normalized coefficients and [b] white heteroskedasticity adjusted se's and T's. I believe I already know how to do the programming to do these two, at least in simple unweighted cases. Now my challenges are just [1] to trap weird cases (e.g., hccm dies because the standard errors cannot be computed), and [2] to follow "proper R rules and regulations."

I started my experiments by copying summary.lm() to summary.lme. But there is some magic that I do not understand. Apparently, the   class(ans) <- "summary.lm"
signals to R that it should not produce an unlisted summary of the components of ans, but that it should print something that is nicely formatted.
  example: y=rnorm(5); x=rnorm(5); m=lm(y~x); summary.lm(m); does exactly this nice output. alas, just replacing the name at the end with

    class(ans) <- "summary.lme"
and typing summary.lme(m), having renamed summary.lm to summary, then loses the nice printout.

so, it seems to me that somewhere R knows that a "summary.lm" object gets special printing. if I have not misunderstood this, then where and how does this magic happen?

advice appreciated.



R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue Jan 02 08:10:01 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 01 Jan 2007 - 21:30:28 GMT.

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