I\'m trying hard to add a regression line on a ggplot. I first tried with abline but I didn\'t manage to make it work. Then I tried this...
data = data.frame
The simple solution using geom_abline:
geom_abline(slope = coef(data.lm)[[2]], intercept = coef(data.lm)[[1]])
Where data.lm is an lm object, and coef(data.lm) looks something like this:
> coef(data.lm)
(Intercept) DepDelay
-2.006045 1.025109
The numeric indexing assumes that (Intercept) is listed first, which is the case if the model includes an intercept. If you have some other linear model object, just plug in the slope and intercept values similarly.