[R] adding linear regression data to plot

Peter Ehlers ehlers at ucalgary.ca
Wed Mar 16 19:01:49 CET 2011


On 2011-03-16 08:47, 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.

It seems that you need to discover the ever-useful str() function.
str(summary(your model)) will show you that you can get:

  summary(model)$r.squared

etc.
For the coefficients, I would use: coef(model).

Peter Ehlers

>
> --
> View this message in context: http://r.789695.n4.nabble.com/adding-linear-regression-data-to-plot-tp3357946p3382135.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list