Description Usage Arguments Value Note References Examples
View source: R/02_QC_Violations.R
function that calculates QC violations on sequentially ordered data based on the following 4 rules:
Violation Same Side: 8 or more consecutive, same-side points
Violation 1 Sigma: 4 or more consecutive, same-side points exceeding 1 sigma
Violation 2 Sigma: 2 or more consecutive, same-side points exceeding 2 sigma
Violation 3 Sigma: any points exceeding 3 sigma
1 2 |
data |
vector or dataframe, as indicated below for each chart type
|
value |
Studentized Charts: numeric vector in dataframe with values of interest |
grouping |
Studentized Charts: single factor/variable to split the dataframe "values" by |
formula |
Studentized 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 |
method |
string, calling the following methods:
|
... |
further arguments passed to or from other methods. |
a dataframe, with the following columns
data: The input data if XmR, mean or median by group for Studentized methods
z_score: z-score for the data point
Index: number, indicating the order of the input data
Violation_Result: description of the type of test being run.
Violation Same Side: 8 or more consecutive, same-side points
Violation 1 Sigma: 4 or more consecutive, same-side points exceeding 1 sigma
Violation 2 Sigma: 2 or more consecutive, same-side points exceeding 2 sigma
Violation 3 Sigma: any points exceeding 3 sigma
Index: boolean, does the data point violate the rule?
If using the formula argument do not use value and group arguments.
Wheeler, DJ, and DS Chambers. Understanding Statistical Process Control, 2nd Ed. Knoxville, TN: SPC, 1992. Print.
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 | #####################################
# Example 1: XmR Check Violations #
#####################################
# Load Libraries ----------------------------------------------------------
require(ggQC)
# Setup Data --------------------------------------------------------------
set.seed(5555)
QC_XmR <- data.frame(
data = c(c(-1, 2.3, 2.4, 2.5), #Outlier Data
sample(c(rnorm(60),5,-5), 62, replace = FALSE), #Normal Data
c(1,-.3, -2.4,-2.6,-2.5,-2.7, .3)), #Outlier Data
Run_Order = 1:73 #Run Order
)
QC_Vs <- QC_Violations(data = QC_XmR$data, method = "XmR")
#######################################
# Example 2: Xbar Check Violations #
#######################################
# Setup Some Data ------------------------------------------------------------
QC_xBar.rBar <- do.call(rbind, lapply(1:3, function(X){
set.seed(5555+X) #Loop over 3 seeds
data.frame(
sub_group = rep(1:42), #Define Subgroups
sub_class = letters[X],
c(
c(runif(n = 5, min = 2.0,3.2)), #Outlier Data
sample(c(rnorm(30),5,-4), 32, replace = FALSE), #Normal Data
c(runif(n = 5, min = -3.2, max = -2.0)) #Outlier Data
)
)
}
)
)
colnames(QC_xBar.rBar) <- c("sub_group","sub_class", "value")
QC_Vs <- QC_Violations(data = QC_xBar.rBar,
formula = value~sub_group,
method = "xBar.rBar")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.