QC_Lines: Calculate QC Limits

Description Usage Arguments Value Note References Examples

View source: R/03_Summay_FUNs.R

Description

Calculates QC chart lines for the following chart types and reports in a dataframe:

Usage

1
2
QC_Lines(data = NULL, value = NULL, grouping = NULL,
  formula = NULL, n = NULL, method = "xBar.rBar", na.rm = FALSE)

Arguments

data

vector or dataframe, as indicated below for each chart type

  • Individuals & Attribute Charts: vector of values;

  • Studentized & Dispersion Charts: dataframe

value

string, Studentized Charts and Dispersion Charts, numeric vector in dataframe with values of interest

grouping

string, Studentized Charts and Dispersion Charts: single factor/variable to split the dataframe "values" by

formula

Studentized Charts and Dispersion Charts: a formula, such as y ~ x1 + x2, where the y variable is numeric data to be split into groups according to the grouping x factors/variables

n

number or vector as indicated below for each chart type.

  • Individuals Charts: No effect

  • Attribute Charts: (p and u) vector, indicating sample area of opportunity.

  • Attribute Charts: (np) number, indicating constant sampling area of opportunity.

  • Studentized Charts: number, user specified subgroup size.

  • Dispersion Charts: No effect

method

string, calling the following methods:

  • Individuals Charts: mR, XmR,

  • Attribute Charts: c, np, p, u,

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

  • Dispersion Charts: rBar, rMedian, sBar.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

a dataframe,

Note

If using the formula argument do not use value and group arguments.

References

Wheeler, DJ, and DS Chambers. Understanding Statistical Process Control, 2nd Ed. Knoxville, TN: SPC, 1992. Print.

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
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
#############################################
#  Example 1: Charts other than "p" or "u"  #
#############################################

# Load Libraries ----------------------------------------------------------
 require(ggQC)
 require(plyr)
 require(ggplot2)

# Setup Data --------------------------------------------------------------
 set.seed(5555)
 Process1 <- data.frame(processID = as.factor(rep(1,100)),
                        metric_value = rnorm(100,0,1),
                        subgroup_sample=rep(1:20, each=5),
                        Process_run_id = 1:100)
 set.seed(5555)
 Process2 <- data.frame(processID = as.factor(rep(2,100)),
                        metric_value = rnorm(100,5, 1),
                        subgroup_sample=rep(1:10, each=10),
                        Process_run_id = 101:200)

 Both_Processes <- rbind(Process1, Process2)

# QC Values For Individuals -----------------------------------------------
 # All Together
   QC_Lines(data = Both_Processes$metric_value, method = "XmR")


 # For Each Process
   ddply(Both_Processes, .variables = "processID",
     .fun =function(df){
       QC_Lines(data = df$metric_value, method = "XmR")
     }
   )

# QC Values For Studentized Runs-------------------------------------------
 # All Together
   QC_Lines(data = Both_Processes,
        formula = metric_value ~ subgroup_sample)


 # For Each Process
   ddply(Both_Processes, .variables = "processID",
     .fun =function(df){
       QC_Lines(data = df, formula = metric_value ~ subgroup_sample)
     }
   )


########################
#  Example 2 "p" data  #
########################

# Setup p Data ------------------------------------------------------------
 set.seed(5555)
 bin_data <- data.frame(
   trial = 1:30,
   Num_Incomplete_Items = rpois(n = 30, lambda = 30),
   Num_Items_in_Set = runif(n = 30, min = 50, max = 100))

 bin_data$Proportion_Incomplete <- bin_data$Num_Incomplete_Items/bin_data$Num_Items_in_Set

# QC_Lines for "p" data ---------------------------------------------------
 QC_Lines(data = bin_data$Proportion_Incomplete,
        n = bin_data$Num_Items_in_Set, method="p")


########################
#  Example 3 "u" data  #
########################

# Setup u Data ------------------------------------------------------------
 set.seed(5555)
 bin_data <- data.frame(
   trial=1:30,
   Num_of_Blemishes = rpois(n = 30, lambda = 30),
   Num_Items_Inspected = runif(n = 30, min = 50, max = 100))

 bin_data$Blemish_Rate <- bin_data$Num_of_Blemishes/bin_data$Num_Items_Inspected


# QC Lines for "u" data ---------------------------------------------------
 QC_Lines(data = bin_data$Blemish_Rate,
        n = bin_data$Num_Items_Inspected, method="u")

Example output

Loading required package: plyr
Loading required package: ggplot2
  xBar_one_LCL    mean xBar_one_UCL mR_LCL        mR   mR_UCL
1  -0.04192909 2.57306     5.188049      0 0.9830786 3.212701
  processID xBar_one_LCL      mean xBar_one_UCL mR_LCL        mR  mR_UCL
1         1     -2.48452 0.0730601      2.63064      0 0.9614964 3.14217
2         2      2.51548 5.0730601      7.63064      0 0.9614964 3.14217
  rBar_LCL     rBar rBar_UCL d2_N xBar_rBar_LCL xBar_Bar xBar_rBar_UCL
1  1.03567 4.643781 8.251892   10     0.3113718 1.742881      3.174391
  processID  rBar_LCL     rBar rBar_UCL d2_N xBar_rBar_LCL  xBar_Bar
1         1 0.0000000 1.977810 4.182078    5     -1.067779 0.0730601
2         2 0.5650788 2.533724 4.502370   10      4.292005 5.0730601
  xBar_rBar_UCL
1      1.213899
2      5.854116
    pBar_LCL      pBar  pBar_UCL
1  0.2087166 0.3961668 0.5836170
2  0.2162050 0.3961668 0.5761287
3  0.2114163 0.3961668 0.5809173
4  0.2444401 0.3961668 0.5478935
5  0.2168088 0.3961668 0.5755248
6  0.2047938 0.3961668 0.5875398
7  0.2121269 0.3961668 0.5802068
8  0.2358058 0.3961668 0.5565278
9  0.2462533 0.3961668 0.5460803
10 0.2124208 0.3961668 0.5799129
11 0.2412450 0.3961668 0.5510887
12 0.2215297 0.3961668 0.5708039
13 0.2307907 0.3961668 0.5615430
14 0.2346510 0.3961668 0.5576827
15 0.2309508 0.3961668 0.5613829
16 0.2304506 0.3961668 0.5618831
17 0.2461250 0.3961668 0.5462086
18 0.2405469 0.3961668 0.5517867
19 0.2005785 0.3961668 0.5917551
20 0.2253713 0.3961668 0.5669624
21 0.2406661 0.3961668 0.5516676
22 0.2375514 0.3961668 0.5547823
23 0.1901049 0.3961668 0.6022288
24 0.2239292 0.3961668 0.5684044
25 0.2170625 0.3961668 0.5752712
26 0.2466673 0.3961668 0.5456664
27 0.2433212 0.3961668 0.5490125
28 0.2371727 0.3961668 0.5551610
29 0.2090274 0.3961668 0.5833063
30 0.2336078 0.3961668 0.5587258
    uBar_LCL      uBar  uBar_UCL
1  0.1549390 0.3961668 0.6373947
2  0.1645757 0.3961668 0.6277580
3  0.1584132 0.3961668 0.6339204
4  0.2009112 0.3961668 0.5914224
5  0.1653528 0.3961668 0.6269809
6  0.1498908 0.3961668 0.6424429
7  0.1593276 0.3961668 0.6330061
8  0.1897998 0.3961668 0.6025338
9  0.2032446 0.3961668 0.5890891
10 0.1597058 0.3961668 0.6326278
11 0.1967994 0.3961668 0.5955343
12 0.1714281 0.3961668 0.6209056
13 0.1833458 0.3961668 0.6089878
14 0.1883136 0.3961668 0.6040200
15 0.1835519 0.3961668 0.6087818
16 0.1829082 0.3961668 0.6094255
17 0.2030795 0.3961668 0.5892541
18 0.1959011 0.3961668 0.5964326
19 0.1444662 0.3961668 0.6478675
20 0.1763717 0.3961668 0.6159620
21 0.1960544 0.3961668 0.5962792
22 0.1920462 0.3961668 0.6002875
23 0.1309877 0.3961668 0.6613459
24 0.1745159 0.3961668 0.6178177
25 0.1656792 0.3961668 0.6266545
26 0.2037773 0.3961668 0.5885564
27 0.1994712 0.3961668 0.5928624
28 0.1915588 0.3961668 0.6007749
29 0.1553389 0.3961668 0.6369948
30 0.1869713 0.3961668 0.6053624

ggQC documentation built on May 1, 2019, 10:26 p.m.