As you draw a linear relationship between x and y, you can use geom_smooth()c method="lm".
ggplot(d, aes(x, y)) + geom_point() + geom_smooth(method="lm",se=FALSE)+
scale_y_log10() + scale_x_log10()
UPDATE
It geom_abline()doesn't seem to have an argument untf=TRUElike for a function abline().
A workaround would be to use a geom_line()new data frame containing y values calculated using the coefficients of your linear model or using a function predict().
ggplot(d, aes(x, y)) + geom_point() +
geom_line(data=data.frame(x=d$x,y=coef(fit)[1]+coef(fit)[2]*d$x))+
scale_y_log10() + scale_x_log10()
ggplot(d, aes(x, y)) + geom_point() +
geom_line(data=data.frame(x=d$x,y=predict(fit)))+
scale_y_log10() + scale_x_log10()

source
share