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

From: Sean O'Riordain <sean.oriordain_at_gmail.com>
Date: Tue 05 Jul 2005 - 23:56:50 EST


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

[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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 06 00:08:10 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:15 EST