-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinear Regression.R
More file actions
28 lines (24 loc) · 885 Bytes
/
Copy pathLinear Regression.R
File metadata and controls
28 lines (24 loc) · 885 Bytes
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
library(tidyverse)
library(modeldata)
theme_set(theme_minimal())
data(penguins)
penguins_sm <- filter(penguins, species != "Adelie")
glimpse(penguins_sm)
ggplot(penguins_sm, aes(x = flipper_length_mm,
y = body_mass_g,
col = species)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE)
model <- lm(body_mass_g ~ flipper_length_mm * species,
data = penguins_sm)
summary(model)
ggplot(penguins_sm, aes(x = flipper_length_mm,
y = body_mass_g,
col = species)) +
geom_point() +
geom_abline(aes(intercept = -3037.196,
slope = 34.573,
col = "Chinstrap"))+
geom_abline(aes(intercept = -3037.196-3750.085,
slope = 34.573 + 20.049,
col = "Gentoo"))