[R-sig-Geo] Adding R-square to linear regression

Thomas Szegvary t.szegvary at unibas.ch
Fri Jul 20 13:38:45 CEST 2007


Dear R users

I want to produce scatter plots from the following data set, using R 2.5.0

summary(comps)
OBS           TM5_STAND      
Min.   :  0.250   Min.   : 4.223 
1st Qu.:  2.440   1st Qu.: 5.539 
Median :  3.936   Median : 6.449 
Mean   :  4.475   Mean   : 6.748 
3rd Qu.:  5.790   3rd Qu.: 7.637
Max.   : 13.283   Max.   :15.452

A simple scatter plot, where I added a linear regression. Here is the code:

plot(comps$OBS,comps$TM5_STAND,xlab="observation",ylab="222-Rn
model",main="TM5_STAND")
abline(lm(comps$TM5_STAND ~ comps$OBS,data=comps))

But as i have to do this for a lot of datasets, I want to compare the
R-square and therefore would like to add the R-Square to the plot
automatically. I have checked faq and a lot of r-sig-geo messages but
haven't found a solution, for this I think trivial problem.

Does someone knows a code for this?
Many thanks

Thomas

__

Thomas Szegvary
Institute of Environmental Geosciences
Department of Geosciences
University of Basel
Bernoullistrasse 30
CH - 4056 Basel

Tel.  41-61-267 04 82
Fax. 41-61-267 04 79
Email: t.szegvary at unibas.ch
www.radon.unibas.ch
www.unibas.ch/environment




More information about the R-sig-Geo mailing list