Add linear regression to ggplot2

Scott Prevost

2019/02/26

Add a simple linear regression line to ggplot scatter plot:

plot <- ggplot(data = z,
               aes(x = xx,
                   y = yy)) +
  geom_point(aes(colour = var),
             alpha = val) +
  geom_smooth(method = "lm",
              colour = "black",
              se = FALSE)