[R] to get the R-Squared value
Greg Hirson
ghirson at ucdavis.edu
Sat Jul 11 00:39:13 CEST 2009
Agus,
Take a look at the summary method for lm - ?summary.lm
x = 1:10
y = 2*x + rnorm(10)
summary(lm(y~x))
names(summary(lm(y~x)))
summary(lm(y~x))$r.squared
# [1] 0.9892822
Hope that helps,
Greg
Agus Susanto wrote:
> Dear all,
> I know there are 'coef', 'predict', 'fit' to get the corresponding
> outputs. Is that possible to get the value of R-squared from a 'lm'
> output?
> Many thanks.
>
> ______________________________________________
> 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.
>
--
Greg Hirson
ghirson at ucdavis.edu
Graduate Student
Agricultural and Environmental Chemistry
1106 Robert Mondavi Institute North
One Shields Avenue
Davis, CA 95616
More information about the R-help
mailing list