[R] how to improve summary.lm

Oliver Kullmann O.Kullmann at swansea.ac.uk
Sun Aug 21 11:02:42 CEST 2011


> When you simply type summary.lm there is an implicit call to
> print.summary.lm but its code is not visible unless you use
> getAnywhere(print.summary.lm ).

Aha, that's great -- now I see all the "\n" (and can get rid off
them ;-)).

> Reading the code you find that the
> coefficient matrix and the significance stars are handled by a
> function , so this should give you what you want:
> 
> printCoefmat(summary(model)$coefficients)
> 

For the record, now I'm using

short_summary_lm = function(L) {
  S = summary(L)
  printCoefmat(S$coefficients, signif.legend=FALSE)
  digits = max(3,getOption("digits")-3)
  cat("R-squared:", formatC(S$r.squared, digits = digits), "\n")
}

Thanks!

Oliver



More information about the R-help mailing list