On 12/02/2010 03:15 PM, Wegan, Michael (DNRE) wrote:
I would like to call both p-values and R-squared values from lm's in a 
function.  I can get the p-values from coef(summary(name.lm))[r,c], however, I 
cannot figure out how to call the R-squared values without manually calling the 
summary and inserting them in the script - which negates the value of 
automating the process through a function.

Thanks,
Mike

I hope this does the trick:

set.seed(1234)
x <- 1:10
y <- (4 + 3*x)+rnorm(10)

my.lm <- lm(y~x)
summary(my.lm)$r.squared
summary(my.lm)$adj.r.squared

Enjoy,
Roland

______________________________________________
R-help@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.

Reply via email to