[R] Presentation of multiple models in one table using xtable

Dieter Menne dieter.menne at menne-biomed.de
Wed Aug 16 08:50:33 CEST 2006


Ajay Narottam Shah <ajayshah <at> mayin.org> writes:

> 
> Consider this situation:
> > x1 <- runif(100); x2 <- runif(100); y <- 2 + 3*x1 - 4*x2 + rnorm(100)
> > m1 <- summary(lm(y ~ x1))
> > m2 <- summary(lm(y ~ x2))
> > m3 <- summary(lm(y ~ x1 + x2))
> 
> Now you have estimated 3 different "competing" models, and suppose you
> want to present the set of models in one table. xtable(m1) is cool,
> but doing that thrice would give us 3 different tables.
> 
> What I want is this one table:
> 
> -----------------------------------------------------------
>                     M1             M2              M3
> -----------------------------------------------------------
> Intercept         0.0816         3.6292         2.2272
>                  (0.5533)       (0.2316)***    (0.2385)***
...... (my gmane newreader complains when I quote too much, and contrary to the
general believe on this list, I think he is right).

There is no standard way of doing this, so the first formatting must be done
manually. For a nice output, check the R2HTML packages and the latex() derivates
in Frank Harrell's Hmisc package.


Dieter



More information about the R-help mailing list