[R] Regression line does not show on scatterplot

Sarah Goslee sarah.goslee at gmail.com
Tue Dec 18 21:47:28 CET 2012


You swapped the x and y variables in the plot command.

lm(y~ x)
but
plot(x, y)

On Tue, Dec 18, 2012 at 3:09 PM, Beatriz González Domínguez
<harimaguadas at gmail.com> wrote:
> Hello,
>
> I have done a scatterplot and now would like to add its regression line but it does not show.
> Below, the code I have used.
>
> lm3 <- lm(data$S_pH_KCl2.5_BCx~data$B_OleicoPF_BCx_per)
> plot(data$S_pH_KCl2.5_BCx, data$B_OleicoPF_BCx_per)
> abline(lm3)
>
> I have been able to do the complete operation using the software STATISTICA but it would be great to do it with R.
>
> If you require more details please get in touch.
>
> Thanks a lot!
>
> Bea

--
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list