#Menginput data

data=read.table(file.choose(),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

#Scatter Plot antara X1 dan Y

library(ggplot2)
model <- lm(Y ~ X1, data = data)
model  # cek intercept & slope
## 
## Call:
## lm(formula = Y ~ X1, data = data)
## 
## Coefficients:
## (Intercept)           X1  
##      19.011        0.518
ggplot(data, aes(x = X1, y = Y)) +
  geom_point(size = 3, color = "pink") +
  geom_abline(intercept = coef(model)[1], slope = coef(model)[2], color ="black") +
  labs(
    title = "Scatter Plot X1 dan Y",
    x = "X1",
    y = "Y"
  ) +
  theme_minimal()

plot(data$X1,data$Y,xlab="X1",ylab="Y",main="Scatter Plot X1 dan Y")
abline(lm(data$Y~data$X1),col="pink",lwd=3)

#Scatter Plot antara X2 dan Y

library(ggplot2)
model <- lm(Y ~ X2, data = data)
model  # cek intercept & slope
## 
## Call:
## lm(formula = Y ~ X2, data = data)
## 
## Coefficients:
## (Intercept)           X2  
##      45.298        4.315
ggplot(data, aes(x = X2, y = Y)) +
  geom_point(size = 3, color = "purple") +
  geom_abline(intercept = coef(model)[1], slope = coef(model)[2], color ="black") +
  labs(
    title = "Scatter Plot X2 dan Y",
    x = "X2",
    y = "Y"
  ) +
  theme_minimal()

plot(data$X2,data$Y,xlab="X2",ylab="Y",main="Scatter Plot X1 dan Y")
abline(lm(data$Y~data$X2),col="purple",lwd=3)

#Scatter Plot X3 dan Y

library(ggplot2)
model <- lm(Y ~ X3, data = data)
model  # cek intercept & slope
## 
## Call:
## lm(formula = Y ~ X3, data = data)
## 
## Coefficients:
## (Intercept)           X3  
##       27.19         1.14
ggplot(data, aes(x = X3, y = Y)) +
  geom_point(size = 3, color = "yellow") +
  geom_abline(intercept = coef(model)[1], slope = coef(model)[2], color ="black") +
  labs(
    title = "Scatter Plot X3 dan Y",
    x = "X3",
    y = "Y"
  ) +
  theme_minimal()

plot(data$X3,data$Y,xlab="X1",ylab="Y",main="Scatter Plot X1 dan Y")
abline(lm(data$Y~data$X3),col="yellow",lwd=3)