stat_QC_Capability: Auto QC Capability Stat Function

Description Usage Arguments Value See Also Examples

Description

Draws lines, lables and summary statistics. Works best with histogram and density plots.

Usage

1
2
3
4
5
stat_QC_Capability(LSL, USL, method = "xBar.rBar",
  show.lines = c("LSL", "USL"), line.direction = "v",
  show.line.labels = TRUE, line.label.size = 3,
  show.cap.summary = c("Cp", "Cpk", "Pp", "Ppk"), cap.summary.size = 4,
  px = Inf, py = -Inf, digits = 3)

Arguments

LSL

numeric, Customer's lower specification limit

USL

numeric, Customer's Upper specification limit

method

string, calling the following methods:

  • Individuals Charts: XmR,

  • Studentized Charts: xBar.rBar, xBar.rMedian, xBar.sBar, xMedian.rBar, xMedian.rMedian

show.lines

vector, indicating which lines to draw ie., c("LCL", "LSL", "X", "USL", "UCL")

  • LCL: Lower Control Limit

  • LSL: Lower Specification Limit

  • X: Process Center

  • USL: Upper Specification Limit

  • UCL: Upper Control Limit

line.direction

string "v" or "h", specifies which direction to draw lines.

show.line.labels

boolean, if TRUE then draw.

line.label.size

numeric, control the size of the line labels.

show.cap.summary

vector, indicating which lines to draw ie., c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", "LCL", "X", "UCL", "Sig"). The order given in the vector is the order presented in the graph.

  • TOL: Tolerance in Sigma Units (USL-LSL)/sigma

  • DNS: Distance to Nearest Specification Limit in Simga Units

  • Cp: Cp (Within)

  • Cpk: Cpk (Within)

  • Pp: Pp (Between)

  • Ppk: Ppk (Between)

  • LCL: Lower Control Limit

  • X: Process Center

  • UCL: Upper Control Limit

  • Sig: Sigma from control charts

cap.summary.size

numeric, control the size/scale of the summary text box.

px

numeric, x position for summary text box. Use Inf to force label to x-limit.

py

numeric, y position for summary text box. Use Inf to force label to y-limits. May also need vjust parameter.

digits

integer, how many digits to report.

Value

capability layer for histogram and density plots.

See Also

for more control over lines, labels, and capability data see the following functions:

Examples

 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
# Load Libraries ----------------------------------------------------------
require(ggQC)
require(ggplot2)
# Setup Data --------------------------------------------------------------
set.seed(5555)
Process1 <- data.frame(ProcessID = as.factor(rep(1,100)),
                      Value = rnorm(100,10,1),
                      Subgroup = rep(1:20, each=5),
                      Process_run_id = 1:100)
set.seed(5556)
Process2 <- data.frame(ProcessID = as.factor(rep(2,100)),
                      Value = rnorm(100,20, 1),
                      Subgroup = rep(1:10, each=10),
                      Process_run_id = 101:200)
df <- rbind(Process1, Process2)

######################
##  Example 1 XmR   ##
######################

##You may need to use the r-studio Zoom for these plots or make the size of the
##stat_QC_cap_summary smaller with size = some number"

# Normal Histogram XmR --------------------------------------------------------
EX1.1 <-  ggplot(df[df$ProcessID == 1,], aes(x=Value, QC.Subgroup=Subgroup)) +
geom_histogram(binwidth = 1, color="purple") +
 geom_hline(yintercept=0, color="grey") +
 stat_QC_Capability(LSL=5, USL=15, show.cap.summary = "all", method="XmR") +
 scale_x_continuous(expand =  expand_scale(mult = c(0.15,.8))) +
 ylim(0,45)
#Ex1.1

# Facet Histogram XmR -----------------------------------------------------
EX1.2 <- ggplot(df[order(df$Process_run_id),],
aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) +
geom_histogram(binwidth = 1) +
 geom_hline(yintercept=0, color="grey") +
 stat_QC_Capability(LSL=5, USL=15, show.cap.summary = "all", method="XmR") +
 scale_x_continuous(expand =  ggplot2::expand_scale(mult = c(0.15,.8))) +
 facet_grid(.~ProcessID, scales = "free_x") + ylim(0,45)
#EX1.2

# Normal Density XmR --------------------------------------------------------
EX1.3 <- ggplot(df[df$ProcessID == 1,], aes(x=Value, QC.Subgroup=Subgroup)) +
geom_density(bw = .4, fill="purple", trim=TRUE) +
 geom_hline(yintercept=0, color="grey") +
 stat_QC_Capability(LSL=5, USL=15, show.cap.summary = "all", method="XmR") +
 scale_x_continuous(expand =  expand_scale(mult = c(0.15,.8)))  + ylim(0,.5)
#EX1.3

########################################
##  Example 2: xBar.rBar or xBar.sBar ##
########################################
# Single Histogram xBar.rBar ----------------------------------------------
EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) +
 geom_histogram(binwidth = 1) +
 stat_QC_Capability(LSL=5, USL=15, method="xBar.rBar") +
 scale_x_continuous(expand =  ggplot2::expand_scale(mult = c(0.15,.8))) #+
#EX2.1

kenithgrey/ggQC documentation built on May 20, 2019, 9:04 a.m.