[R] Insert regression coefficients in a graphic.
dwinsemius at comcast.net
Sat Apr 23 02:48:24 CEST 2011
On Apr 22, 2011, at 2:16 PM, JJCV wrote:
> I did a graphic with the next code:
> plot(T, p, xlab=" ",, ylab=" ", pch=1, cex=2, lwd=2,
> xlim=c(5,30), ylim=c(1000,1015))
> abline(lm(p ~ T), lwd=2)
> lm(p ~ T)
> I want to see the regression coefficient in the graphic. ¿How can I
> do that?
> coef(lm(p ~ T)
> text(10,1010, labels=paste("Slope =", coef(lm(p ~ T) )) )
I suppose you could format it with formatC() or sprintf() if you
wanted it to fewer than 10 decimal places.
David Winsemius, MD
West Hartford, CT
More information about the R-help