Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] finding out more about an object, e.g. lm

Sean O'Riordain

2005-07-05

Replies:

Hi!

I'm trying to use lm(y~x) amongst others in an automated way; I've
gone through the section on indexing in R-lang and I've looked MASS4.
How do I find out more about the structure of the returned object? In
perl I can look at object structure pretty-printed in the debugger -
is there an R equivalent?

I've used coef(lm(y~x))[[1]] and coef(lm(y~x))[[2]] to extract the
intercept; but while summary(lm(y~x)) prints R-squared... it isn't
entirely obvious how to extract this value as a scalar. ?lm doesn't
give me the information

by saying
unlist(summary(lm(y~x))) it prints

$r.squared
[1] 0.2673333

so now I can say
my.r.sq <- summary(lm(y~x))$r.squared

but is there a better way? on my small lm model unlist(lm(y~x)) is a
pretty long list! :-)

Many thanks in advance,
Sean O'Riordain

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.