Dear friends, I am trying to do a simple regression line. When I run abline it doesn't draw well, the line must go through the points, but it does it below
The order of the arguments in your call to plot() do not match the order in lm(). The plot function uses plot(x, y) but lm is lm(y~x). I changed the order in the call to plot.
plot(cars$dist, cars$speed)
modelo1=lm(speed~dist, data = cars)
abline(a=coef(modelo1)[1], b=coef(modelo1)[2])