[R] advice on semi-serious attempt to extend summary
ivo welch
ivowel at gmail.com
Mon Jan 1 22:03:50 CET 2007
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.
regards,
/iaw
More information about the R-help
mailing list