library(ggplot2)
# Input Data
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.3, 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
# a. Scatter X1 dan Y
ggplot(data, aes(x = X1, y = Y)) +
geom_point(color = "deeppink4", size = 3) +
geom_smooth(method = "lm", se = FALSE,
color = "ivory4", linetype = "twodash") +
labs(
title = "Scatter Plot X1 dan Y",
x = "X1", y = "Y"
) +
scale_x_continuous(breaks = seq(65, 105, 2)) +
scale_y_continuous(breaks = seq(52, 72, 1)) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
# b. Scatter X2 dan Y
ggplot(data, aes(x = X2, y = Y)) +
geom_point(color = "#9AC0CD", size = 3) +
geom_smooth(method = "lm", se = FALSE,
color = "#EEE0E5", linetype = "twodash") +
labs(
title = "Scatter Plot X2 dan Y",
x = "X2", y = "Y"
) +
scale_x_continuous(breaks = seq(2, 6, 0.5)) +
scale_y_continuous(breaks = seq(52, 72, 1)) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
# c. Scatter X3 dan Y
ggplot(data, aes(x = X3, y = Y)) +
geom_point(color = "yellow", size = 3) +
geom_smooth(method = "lm", se = FALSE,
color = "hotpink3", linetype = "twodash") +
labs(
title = "Scatter Plot X3 dan Y",
x = "X3", y = "Y"
) +
scale_x_continuous(breaks = seq(25, 40, 1)) +
scale_y_continuous(breaks = seq(52, 72, 1)) +
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.