In this R Markdown, we will make XBar and R Control Chart. Import the data using the code below. I got this data from "Analisis Peta Kendali Variabel pada Pengolahan Produk Minyak Sawit dengan Pendekatan Statistical Quality Control (SQC)" by Wardhana, at all.
library(readxl)
Kadar_ALB <- read_excel("D:/6/Statistika Kendali Mutu/Data UTS.xlsx",
sheet = "Data", range = "B3:H33")
Kadar_ALB
## # A tibble: 30 x 7
## X1 X2 X3 X4 X5 X6 X7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4.59 4.5 4.21 4.26 4.2 4.14 3.9
## 2 3.97 3.92 3.94 3.91 4.45 4.2 4.16
## 3 3.75 3.7 3.81 3.74 3.69 3.66 3.78
## 4 3.84 3.78 3.94 3.7 3.74 3.68 4
## 5 4.37 4.32 4.25 4.16 4.07 3.92 3.87
## 6 4.21 4.13 4.09 3.94 3.89 3.82 3.76
## 7 3.78 3.72 3.68 3.89 3.83 3.76 3.93
## 8 3.76 3.72 3.68 3.63 3.82 3.79 3.75
## 9 4.54 4.83 4.6 4.62 4.66 4.3 4.13
## 10 4.59 4.68 4.65 4.61 4.41 4.05 3.94
## # ... with 20 more rows
After the data imported, let's make control chart. first we will make XBar Control Chart. Use "qcc" packages to make control chart. On phase 1, decide the samples of data to find the control limit. The samples of data that used is the first until fifteenth data.
library(qcc)
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
(q1 <- qcc(Kadar_ALB [1:15,],type = "xbar"))
## List of 11
## $ call : language qcc(data = Kadar_ALB[1:15, ], type = "xbar")
## $ type : chr "xbar"
## $ data.name : chr "Kadar_ALB[1:15, ]"
## $ data : num [1:15, 1:7] 4.59 3.97 3.75 3.84 4.37 4.21 3.78 3.76 4.54 4.59 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:15] 4.26 4.08 3.73 3.81 4.14 ...
## ..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
## $ sizes : int [1:15] 7 7 7 7 7 7 7 7 7 7 ...
## $ center : num 3.98
## $ std.dev : num 0.147
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 3.82 4.15
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
On Phase 1 above, there are data that out of control in 1, 3, 4, 7, 8, 9, 10, 11, 12, 14, and 15. We will remove the outlier and we make control chart using the new data. After, that, continue on phase 2 with enter the sixteenth until the last data.
out1<-c(1,3,4,7,8,9,10,11,12,14,15)
(q1 <- qcc(Kadar_ALB [1:15,][-out1,],type = "xbar"))
## List of 11
## $ call : language qcc(data = Kadar_ALB[1:15, ][-out1, ], type = "xbar")
## $ type : chr "xbar"
## $ data.name : chr "Kadar_ALB[1:15, ][-out1, ]"
## $ data : num [1:4, 1:7] 3.97 4.37 4.21 3.89 3.92 4.32 4.13 3.86 3.94 4.25 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:4] 4.08 4.14 3.98 3.84
## ..- attr(*, "names")= chr [1:4] "1" "2" "3" "4"
## $ sizes : int [1:4] 7 7 7 7
## $ center : num 4.01
## $ std.dev : num 0.155
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 3.83 4.18
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
(q1 <- qcc(Kadar_ALB [1:15,][-out1,],type = "xbar", newdata = Kadar_ALB[16:30,]))
## List of 15
## $ call : language qcc(data = Kadar_ALB[1:15, ][-out1, ], type = "xbar", newdata = Kadar_ALB[16:30, ])
## $ type : chr "xbar"
## $ data.name : chr "Kadar_ALB[1:15, ][-out1, ]"
## $ data : num [1:4, 1:7] 3.97 4.37 4.21 3.89 3.92 4.32 4.13 3.86 3.94 4.25 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:4] 4.08 4.14 3.98 3.84
## ..- attr(*, "names")= chr [1:4] "1" "2" "3" "4"
## $ sizes : int [1:4] 7 7 7 7
## $ center : num 4.01
## $ std.dev : num 0.155
## $ newstats : Named num [1:15] 3.94 4.5 4.27 4.27 4.41 ...
## ..- attr(*, "names")= chr [1:15] "5" "6" "7" "8" ...
## $ newdata : num [1:15, 1:7] 3.98 4.67 4.42 4.25 4.59 4.54 4.71 4.32 4.89 4.36 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 7 7 7 7 7 7 7 7 7 7 ...
## $ newdata.name: chr "Kadar_ALB[16:30, ]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 3.83 4.18
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
We will make R Control Chart with "qcc" packages. On phase 1, we will find the control limit with the samples that we decided before. If there is no outlier, continue to the phase 2.
(q2 <- qcc(Kadar_ALB [1:15,],type = "R"))
## List of 11
## $ call : language qcc(data = Kadar_ALB[1:15, ], type = "R")
## $ type : chr "R"
## $ data.name : chr "Kadar_ALB[1:15, ]"
## $ data : num [1:15, 1:7] 4.59 3.97 3.75 3.84 4.37 4.21 3.78 3.76 4.54 4.59 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:15] 0.69 0.54 0.15 0.32 0.5 0.45 0.25 0.19 0.7 0.74 ...
## ..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
## $ sizes : int [1:15] 7 7 7 7 7 7 7 7 7 7 ...
## $ center : num 0.398
## $ std.dev : num 0.147
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0.0301 0.7659
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
(q2 <- qcc(Kadar_ALB [1:15,],type = "R", newdata = Kadar_ALB[16:30,]))
## List of 15
## $ call : language qcc(data = Kadar_ALB[1:15, ], type = "R", newdata = Kadar_ALB[16:30, ])
## $ type : chr "R"
## $ data.name : chr "Kadar_ALB[1:15, ]"
## $ data : num [1:15, 1:7] 4.59 3.97 3.75 3.84 4.37 4.21 3.78 3.76 4.54 4.59 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:15] 0.69 0.54 0.15 0.32 0.5 0.45 0.25 0.19 0.7 0.74 ...
## ..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
## $ sizes : int [1:15] 7 7 7 7 7 7 7 7 7 7 ...
## $ center : num 0.398
## $ std.dev : num 0.147
## $ newstats : Named num [1:15] 0.35 0.35 0.42 0.4 0.34 ...
## ..- attr(*, "names")= chr [1:15] "16" "17" "18" "19" ...
## $ newdata : num [1:15, 1:7] 3.98 4.67 4.42 4.25 4.59 4.54 4.71 4.32 4.89 4.36 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 7 7 7 7 7 7 7 7 7 7 ...
## $ newdata.name: chr "Kadar_ALB[16:30, ]"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0.0301 0.7659
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
That's all. If there is some mistake, please contact me on email.