if (!require("ggplot2")) install.packages("ggplot2")
## Loading required package: ggplot2
library(ggplot2)
# Membaca data CSV dengan pemisah titik koma (;)
data1 <- read.csv("DATASET 1 REGNON TUGAS 2.csv", sep = ";")
head(data1)
## 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
ggplot(data1, aes(x = X1, y = Y)) +
geom_point(color = "#2b5c8f", size = 2.5, alpha = 0.7) +
geom_smooth(method = "lm", color = "#c0392b", se = TRUE) +
labs(
title = "Scatter Plot Variabel X1 vs Y (Dataset 1)",
x = "Variabel X1",
y = "Variabel Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

ggplot(data1, aes(x = X2, y = Y)) +
geom_point(color = "#27ae60", size = 2.5, alpha = 0.7) +
geom_smooth(method = "lm", color = "#c0392b", se = TRUE) +
labs(
title = "Scatter Plot Variabel X2 vs Y (Dataset 1)",
x = "Variabel X2",
y = "Variabel Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

ggplot(data1, aes(x = X3, y = Y)) +
geom_point(color = "#8e44ad", size = 2.5, alpha = 0.7) +
geom_smooth(method = "lm", color = "#c0392b", se = TRUE) +
labs(
title = "Scatter Plot Variabel X3 vs Y (Dataset 1)",
x = "Variabel X3",
y = "Variabel Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
