-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch6-analisis_data.R
More file actions
56 lines (41 loc) · 1.28 KB
/
ch6-analisis_data.R
File metadata and controls
56 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# A. Dataset ----
## 1. Cek Dataset yang Tersedia ----
data()
## 2. Akses Dataset ----
df <- iris
# B. Ringkasan Data ----
## 1. Cek Data ----
head(df) # cek 6 observasi teratas
head(df, 10) # cek 10 observasi teratas
tail(df) # cek 6 observasi terbawah
tail(df, 10) # cek 10 observasi terbawah
str(df) # cek struktur data
## 2. Statistika Deskriptif ----
summary(df) # ringkasan data
table(df$Species) # tabel kontingensi
mean(df$Sepal.Length, na.rm = TRUE) # nilai rata-rata
median(df$Sepal.Length, na.rm = TRUE) # nilai median
sd(df$Sepal.Length, na.rm = TRUE) # simpangan baku
var(df$Sepal.Length, na.rm = TRUE) # varian
IQR(df$Sepal.Length, na.rm = TRUE) # interquartile range
min(df$Sepal.Length, na.rm = TRUE) # nilai minimum
max(df$Sepal.Length, na.rm = TRUE) # nilai maksimum
range(df$Sepal.Length, na.rm = TRUE) # rentang nilai
quantile(df$Sepal.Length, probs = seq(0, 1, 0.25),
na.rm = TRUE) # kuantil
cor(df[1:4]) # matriks korelasi
# C. Visualisasi Data ----
## 1. Scatterplot Matrix ----
plot(df[1:4])
## 2. Scatterplot ----
plot(x = df$Sepal.Length, y = df$Sepal.Width)
## 3. Boxplot ----
boxplot(df$Sepal.Length)
boxplot(Sepal.Length~Species, data = df)
## 4. Histogram ----
hist(df$Sepal.Length)
## 5. Barplot ----
x <- table(df$Species)
barplot(x)
## 6. pie chart
pie(x)