[R] How to call R-squared values from lm's?

Roland Rau roland.rproject at gmail.com
Thu Dec 2 15:18:54 CET 2010

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:

x <- 1:10
y <- (4 + 3*x)+rnorm(10)

my.lm <- lm(y~x)


More information about the R-help mailing list