I want to extract the linear models given by the ggplot2. Is there a better way to extract these models instead of re-running the individual model separately?
Below is a reproducible code. However, note that Ecdat package is quite big.
library(ggplot2);library(Ecdat)
data('Housing') # from Ecdat
ggplot(Housing, aes(lotsize, price, color = airco, fill = airco)) +
geom_point() +
geom_smooth(method = 'lm') +
ggtitle('Price (lotsize)') + facet_grid( . ~ airco, margins = T) + theme_classic()
Below is the visual output from ggplot. You may notice that we have 3 different models below. I would like to extract the 3 models for further analysis instead of rerunning them with lm().
Thanks!