Description Usage Arguments Examples
View source: R/e_geom_lm_intercept.R
A geom that draws a point at the intercept of linear model estimate
1 2 3 4 5 6 7 8 9 |
... |
all the geom_point arguments |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # without the function
library(magrittr)
library(dplyr)
cars %>%
lm(dist ~ speed, data = .) ->
cars_model
tibble(y_val = cars_model$coefficients[1],
x_val = 0) ->
cars_model_intercept
library(ggplot2)
ggplot(data = cars) +
aes(x = speed, y = dist) +
geom_point() +
geom_smooth(method = lm) +
geom_point(data = cars_model_intercept,
aes(x = x_val,
y = y_val),
color = "red",
size = 3)
# the proto and function
"StatOlsintercept"
e_geom_lm_intercept
# using the function
ggplot(data = cars) +
aes(x = speed, y = dist) +
geom_point() +
geom_smooth(method = lm) +
e_geom_lm_intercept(size = 4) +
aes(color = speed > 12)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.