#MEMANGGIL DATA

data=read.table(file.choose(), header=T)
data
##    NO    X1    X2    X3   X4    X5   X6     Y
## 1   1 12.10 34.05  8.50 2.22 64.81 40.2 73.84
## 2   2 12.45 44.19 10.13 2.20 68.65 32.9 76.87
## 3   3 13.39 38.66  8.99 1.68 69.07 29.7 77.19
## 4   4 14.38 26.30 10.04 2.16 69.18 23.6 69.08
## 5   5 17.86 23.36 10.27 1.46 68.34 33.4 78.27
## 6   6 13.38 10.06 10.87 1.38 70.14 30.1 84.72
## 7   7 18.78 31.46  9.29 0.70 67.29 29.5 76.69
## 8   8 16.64 37.08  9.37 0.56 69.15 25.2 77.12
## 9   9 17.92 17.76  9.91 1.68 65.61 30.7 77.54
## 10 10 19.15 40.31  9.02 1.74 67.78 34.1 46.10
## 11 11 12.12 27.66  9.67 0.46 71.66 32.9 80.83
## 12 12 15.43 24.17  9.20 1.70 65.48 27.9 78.05
## 13 13 18.82 20.48  8.39 6.33 65.92 15.4 77.06
## 14 14 12.42 26.92  8.98 4.54 67.55 34.0 79.69
## 15 15 17.25 24.00  9.14 2.19 69.60 31.6 76.60
## 16 16 12.51 14.56  9.58 1.27 70.04 35.9 81.16
## 17 17 18.31 61.03 10.30 1.15 69.64 32.2 46.98
## 18 18 18.40 32.95  9.85 0.46 70.60 29.4 78.95
## 19 19  7.04  0.11 12.74 0.01 72.02 21.7 87.96
## 20 20 14.59  3.95 10.94 0.20 70.98 25.6 73.80
## 21 21 10.73  1.81 11.31 0.08 72.06 20.7 83.03
## 22 22 10.53  6.24 11.27 0.17 69.78 25.6 78.05
## 23 23 16.41 55.11  8.78 1.40 64.41 29.6 41.12
## 24 24 11.50 35.19  8.96 1.42 67.90 23.8 73.81
## 25 25  8.54 51.69 10.19 2.22 69.57 27.4 78.14
## 26 26  7.01 55.31  9.57 3.22 65.56 15.6 77.29
## 27 27 15.10 64.15  7.06 0.87 70.34 20.3 72.41
## 28 28  9.23 26.92  8.97 1.85 69.64 16.9 79.92
## 29 29  7.98 41.28 10.28 1.51 72.28 24.7 82.28
## 30 30  3.44 14.42 10.41 0.51 72.31 33.8 86.20
## 31 31  7.87 41.91  9.78 1.78 72.20 17.7 82.42
## 32 32  8.21 24.26  9.18 1.82 69.09 11.0 76.65
## 33 33  7.99 41.36  9.69 1.39 70.77 20.2 76.96
## 34 34  7.47 36.67 10.08 2.02 70.11 32.6 82.50
## 35 35  8.04 25.69 10.50 2.06 71.24 28.0 84.33
## 36 36  8.86 55.14  9.37 3.08 63.47 20.7 70.54
## 37 37 16.39 63.23  6.99 1.20 69.58 31.8 65.87
## 38 38  7.54 56.82  9.90 3.57 66.89 28.9 75.32
## 39 39  8.69 49.20  9.93 3.18 70.27 18.4 81.16
## 40 40 11.66 47.18  9.20 2.85 72.24 22.4 80.35
## 41 41  7.44 33.30  9.14 1.51 69.59 14.4 85.35
## 42 42 11.38 35.54  9.13 0.72 67.88 17.7 78.37
## 43 43  8.79 42.52  9.74 3.26 67.82 21.8 75.14
## 44 44  7.89 39.91  9.86 2.67 67.71 17.7 76.75
## 45 45  8.06 24.70  9.32 2.79 69.54 16.0 57.85
## 46 46  9.08 37.52  9.28 2.18 70.25  9.6 80.30

#MEMBUAT SCATTER PLOT X1 DENGAN Y MENGGUNAKAN DATASET 1

library(ggplot2)
model <- lm(Y ~ X1, data = data)
model  # cek intercept & slope
## 
## Call:
## lm(formula = Y ~ X1, data = data)
## 
## Coefficients:
## (Intercept)           X1  
##      88.357       -1.064
ggplot(data, aes(x = X1, y = Y)) +
  geom_point(size = 3, color = "red") +
  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()

#MEMBUAT SCATTER PLOT X2 DENGAN Y MENGGUNAKAN DATASET 1

library(ggplot2)
model <- lm(Y ~ X2, data = data)
model  # cek intercept & slope
## 
## Call:
## lm(formula = Y ~ X2, data = data)
## 
## Coefficients:
## (Intercept)           X2  
##     84.2906      -0.2566
ggplot(data, aes(x = X2, y = Y)) +
  geom_point(size = 3, color = "orange") +
  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()

#MEMBUAT SCATTER PLOT X3 DENGAN Y MENGGUNAKAN DATASET 1

library(ggplot2)
model <- lm(Y ~ X3, data = data)
model  # cek intercept & slope
## 
## Call:
## lm(formula = Y ~ X3, data = data)
## 
## Coefficients:
## (Intercept)           X3  
##      43.834        3.305
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()

#MEMBUAT SCATTER PLOT X4 DENGAN Y MENGGUNAKAN DATASET 1

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

#MEMBUAT SCATTER PLOT X5 DENGAN Y MENGGUNAKAN DATASET 1

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

#MEMBUAT SCATTER PLOT X6 DENGAN Y MENGGUNAKAN DATASET 1

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