library(ggplot2)
library(gridExtra)
data=read.table("C:/Users/MyBook Hype/WPSDrive/979829076594/WPSDrive/dataset 1 regnon.txt", header=T)
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
ggplot(data, aes(x = X1, y = Y)) +
geom_point(color = "maroon", size = 3, alpha = 0.7) +
geom_smooth(method = "lm", color = "pink", se = TRUE) +
labs(
title = "Scatterplot Y vs X1",
x = "Variabel X1",
y = "Variabel Y"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, face = "bold"),
axis.title = element_text(face = "bold")
)
## `geom_smooth()` using formula = 'y ~ x'

ggplot(data, aes(x = X2, y = Y)) +
geom_point(color = "darkgreen", size = 3, alpha = 0.7) +
geom_smooth(method = "lm", color = "green", se = TRUE) +
labs(
title = "Scatterplot Y vs X2",
x = "Variabel X2",
y = "Variabel Y"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, face = "bold"),
axis.title = element_text(face = "bold")
)
## `geom_smooth()` using formula = 'y ~ x'

ggplot(data, aes(x = X3, y = Y)) +
geom_point(color = "purple", size = 3, alpha = 0.7) +
geom_smooth(method = "lm", color = "lavender", se = TRUE) +
labs(
title = "Scatterplot Y vs X3",
x = "Variabel X3",
y = "Variabel Y"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, face = "bold"),
axis.title = element_text(face = "bold")
)
## `geom_smooth()` using formula = 'y ~ x'
