# 1. MEMASUKKAN DATA
library(ggplot2)
data <- data.frame(
Y = c(57.5, 52.8, 61.3, 67.0, 53.5, 62.7, 56.2, 68.5, 69.2),
X1 = c(78, 69, 77, 88, 67, 80, 74, 94, 102),
X2 = c(2.75, 2.15, 4.41, 5.52, 3.21, 4.32, 2.31, 4.30, 3.71),
X3 = c(29.5, 26.3, 32.2, 36.5, 27.2, 27.7, 28.3, 30.3, 28.7)
)
# Menampilkan seluruh data
data
## Y X1 X2 X3
## 1 57.5 78 2.75 29.5
## 2 52.8 69 2.15 26.3
## 3 61.3 77 4.41 32.2
## 4 67.0 88 5.52 36.5
## 5 53.5 67 3.21 27.2
## 6 62.7 80 4.32 27.7
## 7 56.2 74 2.31 28.3
## 8 68.5 94 4.30 30.3
## 9 69.2 102 3.71 28.7
# 2. SCATTER PLOT Y TERHADAP X1
ggplot(data, aes(x = X1, y = Y)) +
geom_point(color = "red", size = 3) +
geom_smooth(
method = "lm",
se = FALSE,
color = "magenta",
linewidth = 1.2
) +
labs(
title = "Scatter Plot Y terhadap X1",
x = "X1",
y = "Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

# 3. SCATTER PLOT Y TERHADAP X2
ggplot(data, aes(x = X2, y = Y)) +
geom_point(color = "red", size = 3) +
geom_smooth(
method = "lm",
se = FALSE,
color = "magenta",
linewidth = 1.2
) +
labs(
title = "Scatter Plot Y terhadap X2",
x = "X2",
y = "Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

# 4. SCATTER PLOT Y TERHADAP X3
ggplot(data, aes(x = X3, y = Y)) +
geom_point(color = "red", size = 3) +
geom_smooth(
method = "lm",
se = FALSE,
color = "magenta",
linewidth = 1.2
) +
labs(
title = "Scatter Plot Y terhadap X3",
x = "X3",
y = "Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
