Status Quo
library(tidyverse)
ggplot(mtcars) +
aes(x = wt, y = mpg) +
geom_point() +
geom_smooth(method = lm, se = F) +
stat_smooth(geom = "point",
xseq = 0, # intercept
method = lm,
color = "red") +
stat_smooth(geom = "point",
xseq = 1, # one unit from x = 0
method = lm,
color = "red") +
stat_smooth(geom = "point",
xseq = mtcars$wt,
method = lm,
color = "blue")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
layer_data(last_plot(), 3)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## x y ymin ymax se flipped_aes PANEL group shape colour
## 1 0 37.28513 33.4505 41.11975 1.877627 FALSE 1 -1 19 red
## size fill alpha stroke
## 1 1.5 NA NA 0.5
layer_data(last_plot(), 4)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## x y ymin ymax se flipped_aes PANEL group shape colour
## 1 1 31.94065 29.18042 34.70089 1.351552 FALSE 1 -1 19 red
## size fill alpha stroke
## 1 1.5 NA NA 0.5
lm(mpg ~ wt, data = mtcars)
##
## Call:
## lm(formula = mpg ~ wt, data = mtcars)
##
## Coefficients:
## (Intercept) wt
## 37.285 -5.344