[R-sig-Geo] Get lm formula

Thomas Szegvary t.szegvary at unibas.ch
Mon Jul 23 16:32:47 CEST 2007


I have several plots where I'd like to add the formula from the linear model
automatically, i.e. in form of y=ax+b, to the plot. I used lm() for a simple
scatter plot.
I was able to add the r-sqare to the plot, using summary(lm$r.square) to
extract the value for r^2. but for the coefficients a and b I couldn't
extract the values like for r-square. I can check the values using coef(lm),
but to be able to write it as text to the plot I should extract the values,
am I right? Or is there a better solution? Does anyone has an idea? I
couldn't find any yet...

Thanks a lot,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