Extracting coefficients of a linear model fitted to a ggplot using geom_smooth () in R

r
ggplot2

#1

Hi,

So, I was doing a quick analysis on a data set and I plotted a scatter plot between two variables and a regression line using geom_smooth(method=“lm”) to see the degree of relationship between the two variables. I was wondering if there is a direct way that i can extract the coefficients of that linear model directly out of ggplot.

Here is what I did.

g2<-ggplot(data1,aes(HousePrice,CrimeRate))+geom_point()+geom_smooth(method = "lm")

Thanks

Neeraj