Re: [R] lm() intercept at the end, rather than at the beginning

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 06 Apr 2007 - 01:26:14 GMT

Try this. It captures the output of x and sets idx to the line numbers of the coefficients, rearranging their order in the next line and printing them out in the line after that.

my.print.summary.lm <- function(x, ...) {

	out <- capture.output(x)
	idx <- seq(grep("Intercept", out), grep("---", out)-1)
	out[idx] <- out[c(idx[-1], idx[1])]
	for(lin in replace(out, idx, out[rev(idx)])) cat(lin, "\n")
 	invisible(x)

}
z <- summary(lm(conc ~ uptake, CO2))
my.print.summary.lm(z)

On 4/5/07, Dimitri Szerman <dimitrijoe@gmail.com> wrote:
> Hi,
>
> I wonder if someone has already figured out a way of making
>
> summary(mylm) # where mylm is an object of the class lm()
>
> to print the "(Intercept)" at the last line, rather than the first
> line of the output. I don't know about, say, biostatistics, but in
> economics the intercept is usually the least interesting of the
> parameters of a regression model. That's why, say, Stata prints by
> default the intercept at the end. Just a suggestion for
> R-developers...
>
> Thanks,
> Dimitri
>
> ______________________________________________
> 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.
>



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 Fri Apr 06 11:36:14 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 Fri 06 Apr 2007 - 02:30:55 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.