Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

QC_Lines

Calculate QC Limits


Description

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

  • 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.

Usage

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,

  • Attribute Data: (p and u) Center Line, Upper Control Limit and Lower Control limit for each point.

  • Other Data: single line dataframe, with relevant control limits noted in column headings.

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

#############################################
#  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")

ggQC

Quality Control Charts for 'ggplot'

v0.0.31
GPL-3 | file LICENSE
Authors
Kenith Grey
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.