[R] Extracting dataset from lm output
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Fri Aug 15 22:25:28 CEST 2008
try this:
x1 <- rnorm(30)
x2 <- rnorm(30)
x3 <- rnorm(30)
y <- 0.5 + x1 - 2*x2 + 3*x3 + rnorm(30)
fm <- lm(y ~ x1 + x2 + x3)
model.frame(fm)
I hope it helps.
Best,
Dimitris
Roberts, Kyle wrote:
> Dear All,
>
> I want to extract the original dataset from a lm output. I know that I
> can get most of it from
>
> model.matrix(lm.out)
>
> but I need the dependent variable to be in the first column. Any ideas?
>
> Thanks,
> Kyle Roberts
>
> ______________________________________________
> R-help at r-project.org 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.
>
>
--
Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://perswww.kuleuven.be/dimitris_rizopoulos/
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list