R Markdown merupakan tools yang disediakan R Studio yang digunakan untuk mencetak project yang dikerjakan dalam bentuk dokumen (HTML, PDF, dan Word), maupun dalam bentuk presentasi.
#Data kualitatif
library(MASS)
head(painters) #sekolah penulis
## Composition Drawing Colour Expression School
## Da Udine 10 8 16 3 A
## Da Vinci 15 16 4 14 A
## Del Piombo 8 13 16 7 A
## Del Sarto 12 16 9 8 A
## Fr. Penni 0 15 8 0 A
## Guilio Romano 15 16 4 14 A
#dari data painters kolom school terdapat data kualitatif
painters$School
## [1] A A A A A A A A A A B B B B B B C C C C C C D D D D D D D D D D E E E E E E
## [39] E F F F F G G G G G G G H H H H
## Levels: A B C D E F G H
#distribusi frekuensi ( rigkasan data )
table(painters$School)
##
## A B C D E F G H
## 10 6 6 10 7 4 7 4
table(painters$Composition)
##
## 0 4 5 6 8 9 10 11 12 13 14 15 16 17 18
## 1 3 1 3 6 1 6 2 4 5 3 14 2 1 2
#nilai maximum frekuensi
max(table(painters$School))
## [1] 10
max(table(painters$Composition))
## [1] 14
#mencari kategori frekuensi maksimum dari kolom School data Painters
table(painters$School)==max(table(painters$School))
##
## A B C D E F G H
## TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE
#atau bisa juga menggunakan fungsi which
which(table(painters$School)==max(table(painters$School)))
## A D
## 1 4
#Distribusi Frekuensi Relatif (distribusi probabilitas)
# frekuensi relatif dari variabel School data Painters adalah sebagai berikut;
options(digits = 2)
table(painters$School)/nrow(painters)
##
## A B C D E F G H
## 0.185 0.111 0.111 0.185 0.130 0.074 0.130 0.074
#atau
table(painters$School)/length(painters$School)
##
## A B C D E F G H
## 0.185 0.111 0.111 0.185 0.130 0.074 0.130 0.074
#membuat prosentasenya
table(painters$School)/nrow(painters)*100
##
## A B C D E F G H
## 18.5 11.1 11.1 18.5 13.0 7.4 13.0 7.4
#Contoh lain mencari nilai relatif frekuensi variabel Composition
table(painters$Composition)/nrow(painters)
##
## 0 4 5 6 8 9 10 11 12 13 14 15 16
## 0.019 0.056 0.019 0.056 0.111 0.019 0.111 0.037 0.074 0.093 0.056 0.259 0.037
## 17 18
## 0.019 0.037
#prosetasenya
table(painters$Composition)/nrow(painters)*100
##
## 0 4 5 6 8 9 10 11 12 13 14 15 16 17 18
## 1.9 5.6 1.9 5.6 11.1 1.9 11.1 3.7 7.4 9.3 5.6 25.9 3.7 1.9 3.7
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.