[R] Regression Line Plot

Marc Schwartz marc_schwartz at comcast.net
Wed Jan 31 18:50:26 CET 2007

On Wed, 2007-01-31 at 09:25 -0800, amna khan wrote:
> Sir I am not finding the function to plot least square regression line on
> type="o" plot of two variables.
> guid me in this regard.

Did you want something like this:

 x <- 1:50
 y <- rnorm(50)
 plot(x, y, type = "o")
 abline(lm(y ~ x))

See ?abline if so.

Alternatively, see ?predict.lm for additional possibilities.


Marc Schwartz

More information about the R-help mailing list