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.
### Gambar 3.69-3.71
data_iq <- read.csv("IQ.csv", header = TRUE)
simpan_skor_IQ <- data_iq[[1]]
# Menampilkan data
simpan_skor_IQ
## [1] 111 111 111 111 111 111 111 110 110 110 110 110 110 110 112 112 112 112 112
## [20] 112 112 113 113 113 113 113 114 114 114 114 115 115 115 116 116 117 90 91
## [39] 92 92 93 93 93 94 94 94 94 95 95 95 95 95 95 96 96 96 96
## [58] 97 97 97 97 97 98 98 98 101 101 101 102 102 103 104 103 102 108 109
## [77] 118
# Menghitung jumlah pengamatan
length(simpan_skor_IQ)
## [1] 77
# Ringkasan data
summary(simpan_skor_IQ)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 90.0 96.0 108.0 104.6 112.0 118.0
hist(
simpan_skor_IQ,
main = "Histogram of simpan_skor_IQ",
xlab = "simpan_skor_IQ",
ylab = "Frequency"
)
### Gambar 3.73
hist(
simpan_skor_IQ,
breaks = c(90, 100, 110, 120),
main = "Contoh Histogram",
xlab = "Skor IQ",
ylab = "Frekuensi",
col = "orange",
border = "black"
)
### Gambar 3.74
hist(
simpan_skor_IQ,
breaks = seq(90, 125, by = 5),
main = "Contoh Histogram",
xlab = "Skor IQ",
ylab = "Frekuensi",
col = c("red", "orange", "yellow", "green", "blue", "purple", "pink"),
border = "black"
)
### Gambar 3.75
hist(
simpan_skor_IQ,
breaks = seq(90, 125, by = 5),
main = "Contoh Histogram",
xlab = "Skor IQ",
ylab = "Frekuensi",
col = rainbow(7),
border = "black"
)
### Gambar 3.76
hist(
simpan_skor_IQ,
breaks = c(90, 117, 120),
xlim = c(90, 125),
main = "Contoh Histogram",
xlab = "Skor IQ",
ylab = "Frekuensi",
col = "red",
border = "black"
)
### Gambar 3.77
library(ggplot2)
data_histogram <- data.frame(
skor_IQ = simpan_skor_IQ
)
ggplot(data_histogram, aes(x = skor_IQ)) +
geom_histogram(
binwidth = 5,
fill = "yellow",
color = "black",
boundary = 90
) +
labs(
title = "Contoh Histogram",
x = "Skor IQ",
y = "Frekuensi"
) +
theme_minimal()
### Gambar 3.78
ggplot(data_histogram, aes(x = skor_IQ, fill = after_stat(x))) +
geom_histogram(
binwidth = 5,
color = "black",
boundary = 90
) +
scale_fill_gradient(
low = "orange",
high = "yellow"
) +
labs(
title = "Contoh Histogram",
x = "Skor IQ",
y = "Frekuensi"
) +
theme_minimal()