Re: [R] Accessing individual variables from summary of lm

From: Mark Difford <mark_difford_at_yahoo.co.uk>
Date: Tue, 22 Jul 2008 23:24:59 -0700 (PDT)

Hi Ben,

> If you wouldn't mind, how do I access the individual components inside > coefficients matrix?

What you want to know about is ?attributes

##
attributes(model)

model$coefficients
model$coefficients[1]
model$coefficients[2:4]
model$coefficients[c(1,5)]

HTH, Mark.

ascentnet wrote:

> 
> Thanks for your help!  If you wouldn't mind, how do I access the
> individual components inside coefficients matrix?
> 
> thanks,
> Ben.
> 
> Paul Smith wrote:

>>
>> On Tue, Jul 22, 2008 at 5:44 AM, ascentnet <ascentnet@yahoo.com> wrote:
>>> I am trying to access the R2, intercept, and slope out of the summary
>>> from an
>>> lm so that I can insert it into a database using RODBC.  How can I
>>> access
>>> these individually?

>>
>> Try:
>>
>> data(swiss)
>> model <- lm(Infant.Mortality ~ .,data=swiss)
>> summary(model)$r.square
>> # The following returns a matrix with the coefficients
>> summary(model)$coefficients
>>
>> Paul
>>
>> ______________________________________________
>> 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.
>>
>>
>
>
-- 
View this message in context: http://www.nabble.com/Accessing-individual-variables-from-summary-of-lm-tp18582274p18604576.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
Received on Wed 23 Jul 2008 - 06:42:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 08:32:09 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.

list of date sections of archive