R Markdown

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

Including Plots

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.

data <- data.frame(
  IQ = c(
    111, 111, 111, 111, 111, 111, 111, 111,
    110, 110, 110, 110, 110, 110,
    112, 112, 112, 112, 112, 112, 112, 112,
    113, 113,
    113, 113, 114, 114, 114, 115, 115, 115,
    116, 116, 117, 90, 91, 92, 92, 93, 93,
    94, 94, 94, 94, 95, 95,
    95, 95, 95, 95, 95, 96, 96, 96,
    97, 97, 97, 97, 97, 98, 98, 98, 98, 98,
    101, 101, 101, 102, 102, 103, 103, 104,
    102, 102, 108, 109, 118
  )
)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.6.2
simpan=read.csv("IQ.csv", header=TRUE)
simpan
##     IQ
## 1  111
## 2  111
## 3  111
## 4  111
## 5  111
## 6  111
## 7  111
## 8  111
## 9  110
## 10 110
## 11 110
## 12 110
## 13 110
## 14 110
## 15 112
## 16 112
## 17 112
## 18 112
## 19 112
## 20 112
## 21 112
## 22 112
## 23 113
## 24 113
## 25 113
## 26 113
## 27 114
## 28 114
## 29 114
## 30 115
## 31 115
## 32 115
## 33 116
## 34 116
## 35 117
## 36  90
## 37  91
## 38  92
## 39  92
## 40  93
## 41  93
## 42  94
## 43  94
## 44  94
## 45  94
## 46  95
## 47  95
## 48  95
## 49  95
## 50  95
## 51  95
## 52  95
## 53  96
## 54  96
## 55  96
## 56  97
## 57  97
## 58  97
## 59  97
## 60  97
## 61  98
## 62  98
## 63  98
## 64  98
## 65  98
## 66 101
## 67 101
## 68 101
## 69 102
## 70 102
## 71 103
## 72 103
## 73 104
## 74 102
## 75 102
## 76 108
## 77 109
## 78 118
simpan_skor_IQ=simpan$IQ
hist(simpan_skor_IQ)

hist(simpan_skor_IQ, col="lightblue")

hist(simpan_skor_IQ, col="darkblue", ylim=c(0,40), main="Contoh Histogram", ylab="Frekuensi")

hist(simpan_skor_IQ, col="orange", ylim=c(0,40), main="Contoh Histogram", ylab="Frekuensi", breaks=c(90,100,110,120))

hist(simpan_skor_IQ, col=heat.colors(6), ylim=c(0,30), main="Contoh Histogram", ylab="Frekuensi",
breaks=c(90,95,100,105,110,115,120), xlim=c(90,125))

hist(simpan_skor_IQ, col=heat.colors(6), ylim=c(0,30), main="Contoh Histogram", ylab="Frekuensi",
breaks=c(90,93,96,99,102,105,108,111,114,117,120), xlim=c(90,125))

hist(simpan_skor_IQ, breaks=6, col=heat.colors(6), ylim=c(0,30), main="Contoh Histogram",
ylab="Frekuensi", xlim=c(90,125))

hist(simpan_skor_IQ, breaks=c(90,117,120), ylim=c(0,50), xlim=c(90,125), main="Contoh Histogram",
col=heat.colors(2))

hist(simpan_skor_IQ, breaks=c(90,117,120), ylim=c(0,80), xlim=c(90,125), main="Contoh Histogram",
col=heat.colors(2), freq=TRUE)
## Warning in plot.histogram(r, freq = freq1, col = col, border = border, angle =
## angle, : the AREAS in the plot are wrong -- rather use 'freq = FALSE'

hist(simpan_skor_IQ, breaks=c(90,92,97,117,120), ylim=c(0,80), xlim=c(90,125), main="Contoh Histogram",
col=heat.colors(4), freq=TRUE)
## Warning in plot.histogram(r, freq = freq1, col = col, border = border, angle =
## angle, : the AREAS in the plot are wrong -- rather use 'freq = FALSE'

ggplot(data=simpan, aes(IQ)) + geom_histogram(breaks=c(90,95,100,105,110,115,120), col="darkblue",
fill=heat.colors(6))

ggplot(data=simpan, aes(IQ)) + geom_histogram(breaks=c(90,95,100,105,110,115,120), col="red",
aes(fill=..count..)) + labs(title="Contoh Histogram") + labs(x="IQ", y="Jumlah") +
xlim(c(90,125)) + ylim(c(0,20)) + scale_fill_gradient("count", low="green", high="red")
## Warning: The dot-dot notation (`..count..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(count)` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_bar()`).

ggplot(data=simpan, aes(IQ)) + geom_histogram(breaks=c(90,93,96,99,102,105,111,114,117,120),
col="darkblue", fill=heat.colors(9), aes(fill=..count..)) + labs(title="Contoh Histogram") +
labs(x="IQ", y="Jumlah") + xlim(c(90,125)) + ylim(c(0,20)) + scale_fill_gradient("count",
low=heat.colors(9), high=heat.colors(9))

ggplot(data=simpan, aes(IQ)) + geom_histogram(breaks=c(90,95,100,105,110,115,120), col="darkblue",
fill=heat.colors(6))