Skip to content
Prev 2363 / 29559 Next

Adding R-square to linear regression

Thomas,
 Can you not use text() to add a label? If you are using lm() to generate
the regression you can get at the R.sq by calling summary:
summary(c)$r.squared [there's also an adj.r.squared, have a look at
summary.lm]
So something along the lines of
text(x=xpos,y=ypos,summary(obj)$r.squared)
ought to work, see code below
Hth
rob


a=c(1,2,3,4,5)
b=c(1,3,2,5,4)
c=lm(a~b)
summary(c)$r.squared
plot(a~b)
text(x=2,y=2,summary(c)$r.squared)

*** Want to know about Britain's birds? Try  www.bto.org/birdfacts ***

Dr Rob Robinson, Senior Population Biologist
British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
Ph: +44 (0)1842 750050         E: rob.robinson at bto.org
Fx: +44 (0)1842 750030         W: http://www.bto.org
eSafe scanned this email for viruses, vandals and malicious content (!)

==== "How can anyone be enlightened, when truth is so poorly lit" =====