lm1 <- lm(mirex~weight, data=Mirex)
rSquared(lm1)
rSquared(lm1,digits=3)
rSquared(lm1,digits=1,percent=TRUE)
## rSquared only works with lm objects
if (FALSE) {
nls1 <- nls(mirex~a*weight^b,data=Mirex,start=list(a=1,b=1))
rSquared(nls1)
}
Run the code above in your browser using DataLab