-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
101 lines (87 loc) · 3.75 KB
/
server.R
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# server.R
# cpk_app
library(ggplot2)
shinyServer(
function(input, output) {
### Cp ###
output$text.cp1 <- renderText({
alpha <- 1 - input$conf.cp
conf2 <- 100*input$conf.cp
cp.lcl <- input$cp * sqrt(qchisq(alpha/2, input$n.cp - 1)/(input$n.cp - 1))
cp.lcl <- sprintf("%.2f", round(cp.lcl, 2))
cp.ucl <- input$cp * sqrt(qchisq(1 - alpha/2, input$n.cp - 1)/(input$n.cp - 1))
cp.ucl <- sprintf("%.2f", round(cp.ucl, 2))
paste("The ", conf2, "% confidence interval for a Cp of ", input$cp, " is (",
cp.lcl, ", ", cp.ucl, ").", sep = "")
})
output$text.cp2 <- renderText({
alpha <- 1 - input$conf.cp
conf2 <- 100*input$conf.cp
lcb <- input$cp / sqrt(qchisq(alpha/2, input$n.cp - 1)/(input$n.cp - 1))
lcb <- sprintf("%.2f", round(lcb, 2))
paste("The minimum value of Cp for which the process is considered capable ",
conf2, "% of the time is ", lcb, ".", sep = "")
})
output$plot.cp2 <- renderPlot({
n.vec <- c(5:250)
alpha <- 1 - input$conf.cp
lcb.cp <- input$cp / sqrt(qchisq(alpha/2, input$n.cp - 1)/(input$n.cp - 1))
lcb.cp.vec <- input$cp / sqrt(qchisq(alpha/2, n.vec - 1)/(n.vec - 1))
qplot(n.vec, lcb.cp.vec, geom = "line") +
xlab('Sample Size (n)') +
ylab('Minimum Cp') +
ggtitle('Lower Confidence Bound for Cp') +
geom_point(aes(x = input$n.cp, y = lcb.cp), color = "red", size = 2)
})
output$table.cp2 <- renderDataTable({
n.vec <- c(5:250)
alpha <- 1 - input$conf.cp
lcb.cp <- input$cp / sqrt(qchisq(alpha/2, input$n.cp - 1)/(input$n.cp - 1))
lcb.cp.vec <- input$cp / sqrt(qchisq(alpha/2, n.vec - 1)/(n.vec - 1))
lcb.cp.vec <- sprintf("%.2f", round(lcb.cp.vec, 2))
cptable <- data.frame(n.vec, lcb.cp.vec)
names(cptable) <- c("Sample Size", "Lower Confidence Bound")
cptable
})
### Cpk ###
output$text.cpk1 <- renderText({
alpha <- 1 - input$conf.cpk
conf2 <- 100*input$conf.cpk
cpk.lcl <- input$cpk * (1 - qnorm(1 - alpha/2)/sqrt(2*input$n.cpk - 2))
cpk.lcl <- sprintf("%.2f", round(cpk.lcl, 2))
cpk.ucl <- input$cpk * (1 + qnorm(1 - alpha/2)/sqrt(2*input$n.cpk - 2))
cpk.ucl <- sprintf("%.2f", round(cpk.ucl, 2))
paste("The ", conf2, "% confidence interval for a Cpk of ", input$cpk, " is (",
cpk.lcl, ", ", cpk.ucl, ").", sep = "")
})
output$text.cpk2 <- renderText({
alpha <- 1 - input$conf.cpk
conf2 <- 100*input$conf.cpk
lcb.cpk <- input$cpk/(1 - qnorm(1 - alpha/2)/sqrt(2*input$n.cpk - 2))
lcb.cpk <- sprintf("%.2f", round(lcb.cpk, 2))
paste("The minimum value of Cpk for which the process is considered capable ",
conf2, "% of the time is ", lcb.cpk, ".", sep = "")
})
output$plot.cpk2 <- renderPlot({
n.vec <- c(5:250)
alpha <- 1 - input$conf.cpk
lcb.cpk <- input$cpk/(1 - qnorm(1 - alpha/2)/sqrt(2*input$n.cpk - 2))
lcb.cpk.vec <- input$cpk/(1 - qnorm(1 - alpha/2)/sqrt(2*n.vec - 2))
qplot(n.vec, lcb.cpk.vec, geom = "line") +
xlab('Sample Size (n)') +
ylab('Minimum Cpk') +
ggtitle('Lower Confidence Bound for Cpk') +
geom_point(aes(x = input$n.cpk, y = lcb.cpk), color = "red", size = 2)
})
output$table.cpk2 <- renderDataTable({
n.vec <- c(5:250)
alpha <- 1 - input$conf.cpk
lcb.cpk <- input$cpk/(1 - qnorm(1 - alpha/2)/sqrt(2*input$n.cpk - 2))
lcb.cpk.vec <- input$cpk/(1 - qnorm(1 - alpha/2)/sqrt(2*n.vec - 2))
lcb.cpk.vec <- sprintf("%.2f", round(lcb.cpk.vec, 2))
cpktable <- data.frame(n.vec, lcb.cpk.vec)
names(cpktable) <- c("Sample Size", "Lower Confidence Bound")
cpktable
})
}
)