Anda di halaman 1dari 10

TUGAS UJIAN AKHIR SEMESTER KOMPUTASI STATISTIKA

KELAS: C

NAMA KELOMPOK:

Screenshot tampilan hasil R Shiny:

a. Metode Diagram C (Pengendalian Kualitas)

Gambar 1.C Chart (jumlah kecacatan)

Dalam analisa menggunakan C Chart atau jumlah kesalahan atau defect yang terjadi
dalam memproduksi donat yang mengalami kegegalan antara lain gosong, ukuran tidak
sesuai hingga gompel dengan presentase kecacatan dalam produk tersebut adalah 10% dari
24 bulan memproduksi doat terlihat pada bulan ke 3 paling outlier
b. Metode Diagram U (Pengendalian Kualitas)
Gambar 2.2 U Chart (per unit kecacatan)

Dari U Chart diatas diketahui bahwa kegagalan dalam memproduksi donat yang gosong
dari 24 bulan dimana dimulai dari tahun 2015 hingga 2016 apabila menggunakan tingkat
kecacatan sebesar 0.1 atau 10% maka diketahui bahwa produksi donat yang paling banyak
mengalami kecacatan (gosong adalah pada bulan ke 2 dan 4 sehingga perlu dilakukan
evaluasi lebih.

 Syntax yang digunakan:


1. Server.R untuk diagram C
library(shiny)
library(ggvis)
library(dplyr)

shinyServer(function(input, output) {

samp_data <- reactive({


samp <- data.frame(defects = rbinom(input$m * input$reps, input$n,
input$p),
month = 1:input$m,
run = as.factor(rep(1:input$reps, each =
input$m)),
n = input$n) %>%
mutate(defectsp = defects / n)
})

samp_data_plus <- reactive({


# add the thresholds based on standard deviations, etc

# overall limits, based on null hypothesis of true rate is the


target:
sigma <- sqrt(input$thresh * (1 - input$thresh) / input$n)
upper <- input$thresh + 3 * sigma

# create a data frame of the simulated data plus thresholds etc


tmp <- samp_data() %>%
# add the overall limits:
mutate(upper = upper,
thresh = input$thresh) %>%
# add the cumulative results for each run including confidence
intervals:
group_by(run) %>%
mutate(meandefectsp = mean(defectsp),
cumdefects = cumsum(defects),
cumn = cumsum(n),
cumdefectp = cumdefects / cumn,
cumsigma = sqrt(cumdefectp * (1 - cumdefectp) / cumn),
cumupper = cumdefectp + 1.96 * cumsigma,
cumlower = cumdefectp - 1.96 * cumsigma)

return(tmp)

})

# draw the two charts:


samp_data_plus %>%
ggvis(x = ~month, y = ~defectsp, stroke = ~run) %>%
layer_lines() %>%
layer_points(fill = ~run) %>%
layer_lines(y = ~upper, stroke := "black", strokeDash := 6,
strokeWidth := 3) %>%
layer_lines(y = ~thresh, stroke := "black", strokeWidth := 3) %>%
hide_legend(scales = "stroke") %>%
hide_legend(scales = "fill") %>%
add_axis("y", title = "Proportion of defects", title_offset = 50) %>
%
bind_shiny("controlChart")

samp_data_plus %>%
filter(run == 1) %>%
ggvis(x = ~month) %>%
layer_ribbons(y = ~cumupper, y2 = ~cumlower, fill := "grey") %>%
layer_lines(y = ~thresh, stroke := "black", strokeWidth := 3) %>%
add_axis("y", title = "Proportion of defects", title_offset = 50) %>
%
bind_shiny("ribbonChart")

})
2. ui.R untuk diagram C

library(shiny)

library(ggvis)

shinyUI(fluidPage(

# Application title

titlePanel("Grafik Kendali C"),

# Sidebar with a slider input for the number of bins

sidebarLayout(

sidebarPanel(

sliderInput("n",

"Data jumlah produksi per bulan:",

min = 43200,

max = 47800,

value = 24),

sliderInput("reps",

"Jumlah Chart yang Ditampilkan:",

min = 1,

max = 25,

value = 1),

sliderInput("m",

"Jumlah bulan untuk produksi:",

min = 1,
max = 24,

value = 24),

numericInput("p",

"Tingkat Kecacatan yang Sebenenarnya",

min = 0, max = 1, step = 0.01,

value = 0.15),

numericInput("thresh",

"Tingkat Kecacatan Maksimum",

min = 0, max = 1, step = 0.01,

value = 0.10),

p(

""),

HTML(

""

),

p(""),

p(""),

p("")

),

# Show a plot of the generated distribution

mainPanel(

h3("Diagram C untuk Produksi Donat per Bulan"),

ggvisOutput("controlChart"),

h3("Selang Kepercayaan untuk Produksi Donat"),

ggvisOutput("ribbonChart")
)

))

3. server.R untuk diagram U


library(shiny)

library(ggvis)

library(dplyr)

shinyServer(function(input, output) {

samp_data <- reactive({

samp <- data.frame(defects = rbinom(input$m * input$reps, input$n,


input$p),

month = 1:input$m,

run = as.factor(rep(1:input$reps, each =


input$m)),

n = input$n) %>%

mutate(defectsp = defects / n)

})

samp_data_plus <- reactive({

# add the thresholds based on standard deviations, etc

# overall limits, based on null hypothesis of true rate is the


target:
unit=input$thresh/input$n
upper <- (input$thresh/input$n) + (3 *
sqrt((input$thresh/input$n)/input$n))

# create a data frame of the simulated data plus thresholds etc

tmp <- samp_data() %>%

# add the overall limits:

mutate(upper = upper,

thresh = input$thresh) %>%

# add the cumulative results for each run including confidence


intervals:

group_by(run) %>%

mutate(meandefectsp = mean(defectsp),

cumdefects = cumsum(defects),

cumn = cumsum(n),

cumdefectp = cumdefects / cumn,

cumupper = cumdefectp + 1.96 * sqrt(cumdefectp),

cumlower = cumdefectp - 1.96 * sqrt(cumdefectp))

return(tmp)

})

# draw the two charts:

samp_data_plus %>%

ggvis(x = ~month, y = ~defectsp, stroke = ~run) %>%

layer_lines() %>%
layer_points(fill = ~run) %>%

layer_lines(y = ~upper, stroke := "black", strokeDash := 6,


strokeWidth := 3) %>%

layer_lines(y = ~thresh, stroke := "black", strokeWidth := 3) %>%

hide_legend(scales = "stroke") %>%

hide_legend(scales = "fill") %>%

add_axis("y", title = "Proportion of defects", title_offset = 50) %>


%

bind_shiny("controlChart")

samp_data_plus %>%

filter(run == 1) %>%

ggvis(x = ~month) %>%

layer_ribbons(y = ~cumupper, y2 = ~cumlower, fill := "grey") %>%

layer_lines(y = ~thresh, stroke := "black", strokeWidth := 3) %>%

add_axis("y", title = "Proportion of defects", title_offset = 50) %>


%

bind_shiny("ribbonChart")

})

4. ui.R untuk diagram U

library(shiny)

library(ggvis)

shinyUI(fluidPage(
# Application title

titlePanel("Grafik Kendali U"),

# Sidebar with a slider input for the number of bins

sidebarLayout(

sidebarPanel(

sliderInput("n",

"Data Jumlah Produksi Gagal tiap Bulan:",

min = 1000,

max = 2450,

value = 24),

sliderInput("reps",

"Jumlah Chart yang Ditampilkan:",

min = 1,

max = 25,

value = 1),

sliderInput("m",

"Jumlah bulan untuk produksi:",

min = 1,

max = 24,

value = 24),

numericInput("p",

"Tingkat Kecacatan yang Sebenenarnya)",

min = 0, max = 1, step = 0.01,

value = 0.15),
numericInput("thresh",

"Tingkat Kecacatan Maksimum",

min = 0, max = 1, step = 0.01,

value = 0.10),

p(

""),

HTML(

""

),

p(""),

p(""),

p("")

),

# Show a plot of the generated distribution

mainPanel(

h3("Diagram U untuk Produksi Donat per Bulan"),

ggvisOutput("controlChart"),

h3("Selang Kepercayaan untuk Produksi Donat"),

ggvisOutput("ribbonChart")

))

Anda mungkin juga menyukai