'Unique regression coefficients in ggplot in R

How to obtain unique regression coefficients for the regression line in ggplot?

plot<- ggplot(data = df, aes(x = year, y = level, group = id, color=disease))
plot <- plot + geom_line(colour = "gray84") 
plot <- plot+  stat_smooth(aes(group = 1), color=c('black'), size=0.7, method = "lm", se = TRUE, alpha=0.1) +
theme_ipsum() + stat_regline_equation(label.x=1, label.y=100)
plot <- plot + stat_summary(aes(group = 1), geom = "point", fun.y = median, shape = 16, size = 2) +    facet_grid(. ~ df$disease) +
  
print(plot)

Here is my figure

Figure



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source