#DATASET 1
library(ggplot2)
#Buat Data Frame
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)
)
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
#1. Scatter Plot X1 dan Y
ggplot(data, aes(x = X1, y = Y)) +
geom_point(color = "deepskyblue", size = 3.5, alpha = 0.8) +
geom_smooth(method = "lm", se = FALSE, color = "gainsboro", linetype = "dashed") +
labs(
title = "Scatter Plot X1 dan Y",
x = "X1",
y = "Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
#Scatter Plot X2 dan Y
ggplot(data, aes(x = X2, y = Y)) +
geom_point(color = "maroon", size = 3.5, alpha = 0.8) +
geom_smooth(method = "lm", se = FALSE, color = "thistle", linetype = "dashed") +
labs(
title = "Scatter Plot X2 dan Y",
x = "X2",
y = "Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
#Scatter Plot X3 dan Y
ggplot(data, aes(x = X3, y = Y)) +
geom_point(color = "darkgreen", size = 3.5, alpha = 0.8) +
geom_smooth(method = "lm", se = FALSE, color = "springgreen", linetype = "dashed") +
labs(
title = "Scatter Plot X3 dan Y",
x = "X3",
y = "Y"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.