I'm trying to compare the slope and intercept of many separate fitted lines and would like to extract this information from the equations that are shown using stat_poly_eq. I am able to plot all of the data and lines but since in my actual data I has over 50 equations, I'd like a simple way to extract the slope and intercept of each line.
Below is code to generate a similar plot with mtcars.
I'd like to add an output as a tibble with columns for cyl, gear, slope, intercept.
library(tidyverse)
library(ggpmisc)
ggplot(mtcars, aes(x = wt, y = mpg, color = as.character(cyl))) +
geom_point()+
facet_wrap(gear ~ .) +
stat_poly_line(fullrange = TRUE, se = FALSE) +
stat_poly_eq(aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~~~")),
parse=TRUE,label.x.npc = "right")