[R] adding linear regression data to plot

Jim Lemon jim at bitwrit.com.au
Thu Mar 17 09:58:31 CET 2011


On 03/17/2011 02:47 AM, derek wrote:
> I know I can add line to graph with abline(), but I would like to print
> R-squared, F-test value, Residuals  and other statistics from lm() to a
> graph. I don't know how to access the values from summary(), so that I can
> use them in a following code or print them in a graph.
>
Hi derek,
As Peter has already replied, you can use str() to find out the 
components of the summary. Try something like this:

plot(1:10)
library(plotrix)
addtable2plot(2,8,coef(result))

where "result" is what has been returned by the call to "lm".

Jim



More information about the R-help mailing list