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

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jan 1 22:12:14 CET 2007



On 1/1/07, ivo welch <ivowel at gmail.com> wrote:
> 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
> ______________________________________________
> R-help at 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.

More information about the R-help mailing list