Re: [R] plot/lm/abline

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Thu 02 Jun 2005 - 23:34:04 EST

Mathias Hunskår Furevik wrote:
> Hi,
>
> when I run
>
>

>>plot.default(z1, z2, xlab = "x", ylab = "y", main = "xxxx", pch = "+")
>>abline(lm(z1 ~ z2))

>
>
> then the plot is plotted perfectly (scatterplot), however, the lm()
> function doesnt appear on the plot. What could be wrong?
>
> (Yesterday it worked perfectly, with the lm() line.)

You've reversed the order of variables. Try

abline(lm(z2 ~ z1))

Plot takes variables in the order x, y.

lm takes variables in the order y ~ x.

Duncan Murdoch



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 02 23:57:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:21 EST