[R] Extracting dataset from lm output

Roberts, Kyle kyler at mail.smu.edu
Fri Aug 15 22:32:19 CEST 2008


Thanks for the suggestions. I needed it to be a little more generic to capture lm models where the dataset may or may not have been attached. Also, if they specified any interaction effects, I needed to capture them, so model.frame wouldn't work. With Henrique's help, I did this:

new<-model.matrix(lm.out)
new[,1]<-lm.out$model[,1]

This seems to do what I need.

*********************************************************
Dr. J. Kyle Roberts
Department of Literacy, Language, and Learning
School of Education and Human Development
Southern Methodist University
P.O. Box 750381
Dallas, TX  75275
214-768-4494
http://www.hlm-online.com/
*********************************************************

-----Original Message-----
From: Henrique Dallazuanna [mailto:wwwhsd at gmail.com] 
Sent: Friday, August 15, 2008 3:24 PM
To: Roberts, Kyle
Cc: r-help at r-project.org
Subject: Re: [R] Extracting dataset from lm output

Try this:

lm.out$model

On Fri, Aug 15, 2008 at 4:48 PM, Roberts, Kyle <kyler at mail.smu.edu> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list