Title: | Quality Control Charts for 'ggplot' |
---|---|
Description: | Plot single and faceted type quality control charts for 'ggplot'. |
Authors: | Kenith Grey |
Maintainer: | Kenith Grey <[email protected]> |
License: | GPL-3 | file LICENSE |
Version: | 0.0.31 |
Built: | 2024-12-06 06:51:00 UTC |
Source: | CRAN |
function to report listing of quality performance parameters
Proc. Tolerance (sigma): Describes the number of your process sigma (from QC charting) that can fit in your customer's specification window (the larger the better).
DNS (sigma): Distance to Nearest Specification (DNS) limit. Measure of how centered your process is and how close you are to the nearest process limit in sigma units.
Cp: Describes how many times your 6 sigma process window (from QC charting) can fit in your customer's specification window (the larger the better)
Cpk: Describes how centered your process is relative to customer specifications. How many times can you fit a 3 sigma window (from QC charting) between your process center and the nearest customer specification limit.
Pp: Describes how many times your 6 sigma process window (overall standard deviation) can fit in your customer's specification window (the larger the better)
Ppk: Describes how centered your process is relative to customer specifications. How many times can you fit a 3 sigma window (overall standard deviation) between your process center and the nearest customer specification limit.
capability.summary(LSL, USL, QC.Center, QC.Sigma, s.Sigma, digits = 2)
capability.summary(LSL, USL, QC.Center, QC.Sigma, s.Sigma, digits = 2)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Center |
number, the mean or median value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
s.Sigma |
number, the sigma value determined from overall standard deviation (i.e., sd()). |
digits |
integer, how many digits to report. |
data frame , listing of metric labels and value
Calculates lower control limit (LCL) for count data acquired over the same-sized area of opportunity. Negative values are reported as 0.
cBar_LCL(y, na.rm = FALSE, ...)
cBar_LCL(y, na.rm = FALSE, ...)
y |
Vector of count data. Each observation having the same-area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; 3-sigma lower control limit (LCL). Function returns 0 for negative values.
set.seed(5555) y <- rpois(30, 9) cBar_LCL(y)
set.seed(5555) y <- rpois(30, 9) cBar_LCL(y)
Calculates upper control limit (UCL) for count data acquired over the same-sized area of opportunity.
cBar_UCL(y, na.rm = FALSE, ...)
cBar_UCL(y, na.rm = FALSE, ...)
y |
Vector of count data. Each observation having the same-area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; 3-sigma upper control limit (UCL)
set.seed(5555) y <- rpois(30, 9) cBar_UCL(y)
set.seed(5555) y <- rpois(30, 9) cBar_UCL(y)
function to calculate Cp - "The elbowroom or margin your process"
Cp(LSL, USL, QC.Sigma)
Cp(LSL, USL, QC.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
numeric, Cp value (unitless)
function to calculate Cpk - "measure of process centering"
Cpk(LSL, USL, QC.Center, QC.Sigma)
Cpk(LSL, USL, QC.Center, QC.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Center |
number, the mean or median value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
numeric, Cpk value (unitless)
function to calculate a standardized distance to the nearest specification limit (sigma units)
DNS(LSL, USL, QC.Center, QC.Sigma)
DNS(LSL, USL, QC.Center, QC.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Center |
number, the mean or median value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
numeric, standardized distance to the nearest specification limit (sigma units)
function to calculate a standardized distance to the Lower specification limit (sigma units)
LD(LSL, USL, QC.Center, QC.Sigma)
LD(LSL, USL, QC.Center, QC.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Center |
number, the mean or median value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
numeric, standardized distance to the lower specification limit (sigma units)
Calculates the mean one-point moving range used when constructing a moving-range chart.
mR(y, na.rm = TRUE, ...)
mR(y, na.rm = TRUE, ...)
y |
Vector of values |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; mean one-point moving range.
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) mR(values)
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) mR(values)
Calculates a one-point moving range vector given an input vector of values. Output often used to produce mR-chart.
mR_points(y)
mR_points(y)
y |
: vector of values |
Vector of one-point moving range.
y <- seq(-5:5) mR_points(y)
y <- seq(-5:5) mR_points(y)
Calculates the mean one-point moving range UCL used when constructing a moving-range chart.
mR_UCL(y, na.rm = FALSE, ...)
mR_UCL(y, na.rm = FALSE, ...)
y |
Vector of values |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; mean one-point moving range UCL.
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) mR_UCL(values)
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) mR_UCL(values)
Calculates the mean value for binomial count data acquired over the same-sized area of opportunity.
npBar(y, n, na.rm = FALSE, ...)
npBar(y, n, na.rm = FALSE, ...)
y |
Vector of binomial count data (not proportions). Each observation having the same-area of opportunity. |
n |
A number representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; mean value
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) npBar(y = p, n = 30)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) npBar(y = p, n = 30)
Calculates lower control limit (LCL) for binomial count data acquired over the same-sized area of opportunity.
npBar_LCL(y, n, na.rm = FALSE, ...)
npBar_LCL(y, n, na.rm = FALSE, ...)
y |
Vector of binomial count data (not proportions). Each observation having the same-area of opportunity. |
n |
A number representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; 3-sigma upper control limit (LCL)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) npBar_LCL(y = p, n = 30)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) npBar_LCL(y = p, n = 30)
Calculates upper control limit (UCL) for binomial count data acquired over the same-sized area of opportunity.
npBar_UCL(y, n, na.rm = FALSE, ...)
npBar_UCL(y, n, na.rm = FALSE, ...)
y |
Vector of binomial count data (not proportions). Each observation having the same-area of opportunity. |
n |
A number representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; 3-sigma upper control limit (UCL)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) npBar_UCL(y = p, n = 30)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) npBar_UCL(y = p, n = 30)
Calculates overall mean proportion for binomial proportion data acquired over a variable area of opportunity.
pBar(y, n, na.rm = FALSE, ...)
pBar(y, n, na.rm = FALSE, ...)
y |
Vector of binomial proportion data (not counts). Observations may have a different area of opportunity, n. |
n |
A vector representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A vector of mean proportion, length equal to length of parameter y.
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) n <- rpois(100, 100) pBar(y = p/n, n = n)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) n <- rpois(100, 100) pBar(y = p/n, n = n)
Calculates point-wise lower control limit (LCL) for binomial proportion data acquired over a variable area of opportunity.
pBar_LCL(y, n, na.rm = FALSE, ...)
pBar_LCL(y, n, na.rm = FALSE, ...)
y |
Vector of binomial proportion data (not counts). Observations may have a different area of opportunity, n. |
n |
A vector representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A vector; point-wise 3-sigma lower control limit (LCL)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) n <- rpois(100, 100) pBar_LCL(y = p/n, n = n)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) n <- rpois(100, 100) pBar_LCL(y = p/n, n = n)
Calculates point-wise upper control limit (UCL) for binomial proportion data acquired over a variable area of opportunity.
pBar_UCL(y, n, na.rm = FALSE, ...)
pBar_UCL(y, n, na.rm = FALSE, ...)
y |
Vector of binomial proportion data (not counts). Observations may have a different area of opportunity, n. |
n |
A vector representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A vector; point-wise 3-sigma upper control limit (UCL)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) n <- rpois(100, 100) pBar_UCL(y = p/n, n = n)
set.seed(5555) p <- rbinom(n = 100, size = 30, prob = .2) n <- rpois(100, 100) pBar_UCL(y = p/n, n = n)
function to calculate Pp - "The elbowroom or margin your process" uses overall sigma value not the QC chart sigma values.
Pp(LSL, USL, s.Sigma)
Pp(LSL, USL, s.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
s.Sigma |
number, the sigma value determined from overall standard deviation (i.e., sd()). |
numeric, Pp value (unitless)
function to calculate Cpk - "measure of process centering"
Ppk(LSL, USL, QC.Center, s.Sigma)
Ppk(LSL, USL, QC.Center, s.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Center |
number, the mean or median value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
s.Sigma |
number, the sigma value determined from overall standard deviation (i.e., sd()). |
numeric, Ppk value (unitless)
function to calculate a standardized process tolerance with sigma unit
process_tolerance(LSL, USL, QC.Sigma)
process_tolerance(LSL, USL, QC.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
numeric, standardized process tolerance value in sigma units
function to report listing of quality performance parameters
QC_Capability(data = NULL, value = NULL, grouping = NULL, formula = NULL, method = "xBar.rBar", na.rm = FALSE, LSL = NULL, USL = NULL, digits = 2)
QC_Capability(data = NULL, value = NULL, grouping = NULL, formula = NULL, method = "xBar.rBar", na.rm = FALSE, LSL = NULL, USL = NULL, digits = 2)
data |
vector or dataframe, as indicated below for each chart type
|
value |
string, Studentized Charts, name of numeric vector in dataframe with values of interest. |
grouping |
string, Studentized Charts, name of 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 one of the following methods:
|
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit
|
digits |
integer, how many digits to report. |
data frame , listing of metric labels and value
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.
QC_Lines(data = NULL, value = NULL, grouping = NULL, formula = NULL, n = NULL, method = "xBar.rBar", na.rm = FALSE)
QC_Lines(data = NULL, value = NULL, grouping = NULL, formula = NULL, n = NULL, method = "xBar.rBar", na.rm = FALSE)
data |
vector or dataframe, as indicated below for each chart type
|
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.
|
method |
string, calling the following methods:
|
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
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.
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.
############################################# # 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 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")
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
QC_Violations(data, value = NULL, grouping = NULL, formula = NULL, method = NULL, ...)
QC_Violations(data, value = NULL, grouping = NULL, formula = NULL, method = NULL, ...)
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.
##################################### # 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")
##################################### # 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")
Given a set of numbers, function calculates the difference between the maximum and minimum value.
QCrange(y)
QCrange(y)
y |
: vector of values |
a number.
y <- seq(-5:5) QCrange(y)
y <- seq(-5:5) QCrange(y)
Calculates the mean subgroup range used when constructing a XbarR chart.
rBar(data, value, grouping, formula = NULL, ...)
rBar(data, value, grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean subgroup range.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rBar(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rBar(data = df, formula = v~g)
Calculates the mean subgroup range Lower control limit (UCL) used when constructing a XbarR chart.
rBar_LCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
rBar_LCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean subgroup range lower control limit (LCL).
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rBar_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rBar_LCL(data = df, formula = v~g)
Calculates the mean subgroup range upper control limit (UCL) used when constructing a XbarR chart.
rBar_UCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
rBar_UCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean subgroup range upper control limit (UCL).
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rBar_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rBar_UCL(data = df, formula = v~g)
Calculates the median of subgroup ranges, used when constructing xBar_rMedian charts.
rMedian(data, value, grouping, formula = NULL, ...)
rMedian(data, value, grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; median subgroup range.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rMedian(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rMedian(data = df, formula = v~g)
Calculates the median of subgroup range Lower control limit (LCL) used when constructing a xBar_rMedian chart.
rMedian_LCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
rMedian_LCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; median of subgroup range lower control limit (LCL).
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rMedian_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rMedian_LCL(data = df, formula = v~g)
Calculates the median of subgroup range upper control limit (UCL) used when constructing a xBar_rMedian chart.
rMedian_UCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
rMedian_UCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; median of subgroup range upper control limit (UCL).
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rMedian_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) rMedian_UCL(data = df, formula = v~g)
Calculates the mean subgroup standard deviation used when constructing a XbarS chart.
sBar(data, value, grouping, formula = NULL, ...)
sBar(data, value, grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean subgroup standard deviation.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) sBar(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) sBar(data = df, formula = v~g)
Calculates the mean subgroup standard deviation Lower control limit (UCL) used when constructing a XbarS chart.
sBar_LCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
sBar_LCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean subgroup standard deviation lower control limit (LCL).
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) sBar_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) sBar_LCL(data = df, formula = v~g)
Calculates the mean subgroup standard deviation upper control limit (UCL) used when constructing a XbarS chart.
sBar_UCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
sBar_UCL(data = data, value = value, grouping = grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean subgroup standard deviation upper control limit (UCL).
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) sBar_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) sBar_UCL(data = df, formula = v~g)
ggplot stat used to create a mR chart in ggplot
stat_mR(mapping = NULL, data = NULL, geom = "point", position = "identity", show.legend = NA, inherit.aes = TRUE, na.rm = FALSE, color.mr_point = "black", color.mr_line = "black", color.qc_limits = "red", color.qc_center = "blue", ...)
stat_mR(mapping = NULL, data = NULL, geom = "point", position = "identity", show.legend = NA, inherit.aes = TRUE, na.rm = FALSE, color.mr_point = "black", color.mr_line = "black", color.qc_limits = "red", color.qc_center = "blue", ...)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
color.mr_point |
color, to be used for the mR points. |
color.mr_line |
color, to be used for line connecting points. |
color.qc_limits |
color, used to colorize the plot's upper and lower mR control limits. |
color.qc_center |
color, used to colorize the plot's center line. |
... |
Other arguments passed on to |
data need to produce the mR plot in ggplot.
######################### # Example 1: mR Chart # ######################### # Load Libraries ---------------------------------------------------------- require(ggQC) 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(5556) 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) # One Plot Both Processes ------------------------------------------------- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") # Facet Plot - Both Processes --------------------------------------------- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") + facet_grid(.~processID, scales = "free_x")
######################### # Example 1: mR Chart # ######################### # Load Libraries ---------------------------------------------------------- require(ggQC) 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(5556) 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) # One Plot Both Processes ------------------------------------------------- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") # Facet Plot - Both Processes --------------------------------------------- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") + facet_grid(.~processID, scales = "free_x")
stat function to create ggplot Pareto chart
stat_pareto(mapping = NULL, data = NULL, geom = "point", position = "identity", show.legend = NA, inherit.aes = TRUE, group = 1, na.rm = FALSE, point.color = "black", point.size = 2, line.color = "black", line.size = 0.5, bars.fill = c("red", "white"), ...)
stat_pareto(mapping = NULL, data = NULL, geom = "point", position = "identity", show.legend = NA, inherit.aes = TRUE, group = 1, na.rm = FALSE, point.color = "black", point.size = 2, line.color = "black", line.size = 0.5, bars.fill = c("red", "white"), ...)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
group |
defines grouping for variable for pareto plot, default and suggested is 1. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
point.color |
color, used to define point color of cumulative percentage line |
point.size |
number, used to define point size of cumulative percentage line |
line.color |
color, used to define line color of cumulative percentage line |
line.size |
color, used to define line weight of cumulative percentage line |
bars.fill |
character vector length 2, start and end colors for pareto bars. |
... |
Other arguments passed on to |
Pareto plot.
############################ # Example 1: Pareto Plot # ############################ # Load Libraries ---------------------------------------------------------- require(ggQC) require(ggplot2) # Setup Data -------------------------------------------------------------- df <- data.frame( x = letters[1:10], y = as.integer(runif(n = 10, min = 0, max=100)) ) # Render Pareto Plot ------------------------------------------------------ ggplot(df, aes(x=x, y=y)) + stat_pareto(point.color = "red", point.size = 3, line.color = "black", #size.line = 1, bars.fill = c("blue", "orange"), )
############################ # Example 1: Pareto Plot # ############################ # Load Libraries ---------------------------------------------------------- require(ggQC) require(ggplot2) # Setup Data -------------------------------------------------------------- df <- data.frame( x = letters[1:10], y = as.integer(runif(n = 10, min = 0, max=100)) ) # Render Pareto Plot ------------------------------------------------------ ggplot(df, aes(x=x, y=y)) + stat_pareto(point.color = "red", point.size = 3, line.color = "black", #size.line = 1, bars.fill = c("blue", "orange"), )
Produce QC charts with ggplot framework. Support for faceting and layering of multiple QC chart lines on a single plot. Charts supported (see method argument for call):
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.
To label chart lines see stat_QC_labels
stat_QC(mapping = NULL, data = NULL, geom = "hline", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, n = NULL, method = "xBar.rBar", color.qc_limits = "red", color.qc_center = "blue", color.point = "black", color.line = "black", physical.limits = c(NA, NA), auto.label = FALSE, limit.txt.label = c("LCL", "UCL"), label.digits = 1, show.1n2.sigma = FALSE, ...)
stat_QC(mapping = NULL, data = NULL, geom = "hline", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, n = NULL, method = "xBar.rBar", color.qc_limits = "red", color.qc_center = "blue", color.point = "black", color.line = "black", physical.limits = c(NA, NA), auto.label = FALSE, limit.txt.label = c("LCL", "UCL"), label.digits = 1, show.1n2.sigma = FALSE, ...)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
n |
number, for
|
method |
string, calling the following methods:
|
color.qc_limits |
color, used to colorize the plot's upper and lower control limits. |
color.qc_center |
color, used to colorize the plot's center line. |
color.point |
color, used to colorize points in studentized plots. You will need geom_point() for C, P, U, NP, and XmR charts. |
color.line |
color, used to colorize lines connecting points in studentized plots. You will need geom_line() for C, P, U, NP, and XmR charts. |
physical.limits |
vector, specify lower physical boundary and upper physical boundary |
auto.label |
boolean setting, if T labels graph with control limits. |
limit.txt.label |
vector, provides option for naming or not showing the limit text labels (e.g., UCL, LCL)
|
label.digits |
integer, number of decimal places to display. |
show.1n2.sigma |
boolean setting, if T labels graph 1 and 2 sigma lines. Line color is set by color.qc_limits |
... |
Other arguments passed on to |
ggplot control charts.
# Load Libraries ---------------------------------------------------------- require(ggQC) 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(5556) 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) ############################# # Example 1: XmR Chart # ############################# EX1.1 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + geom_point() + geom_line() + stat_QC(method="XmR") + stat_QC_labels(method="XmR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.1 EX1.2 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") + stat_QC_labels(method="mR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.2 ############################# # Example 2: XbarR Chart # ############################# EX2.1 <- ggplot(Both_Processes, aes(x = subgroup_sample, y = metric_value, group = processID)) + stat_summary(fun.y = "mean", color = "blue", geom = c("point")) + stat_summary(fun.y = "mean", color = "blue", geom = c("line")) + stat_QC(method = "xBar.rBar") + facet_grid(.~processID, scales = "free_x") #EX2.1 EX2.2 <- ggplot(Both_Processes, aes(x = subgroup_sample, y = metric_value, group = processID)) + stat_summary(fun.y = "QCrange", color = "blue", geom = "point") + stat_summary(fun.y = "QCrange", color = "blue", geom = "line") + stat_QC(method = "rBar") + ylab("Range") + facet_grid(.~processID, scales = "free_x") #EX2.2 ############################# # Example 3: p Chart # ############################# # p chart Setup ----------------------------------------------------------- set.seed(5556) bin_data <- data.frame( trial=1:30, Num_Incomplete_Items = rpois(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 # Plot p chart ------------------------------------------------------------ EX3.1 <- ggplot(data = bin_data, aes(x=trial, y=Proportion_Incomplete, n=Num_Items_in_Set)) + geom_point() + geom_line() + stat_QC(method = "p") #EX3.1 ############################# # Example 4: u Chart # ############################# # u chart Setup ----------------------------------------------------------- set.seed(5555) bin_data <- data.frame( trial=1:30, Num_of_Blemishes = rpois(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 # Plot u chart ------------------------------------------------------------ EX4.1 <- ggplot(data = bin_data, aes(x=trial, y=Blemish_Rate, n=Num_Items_Inspected)) + geom_point() + geom_line() + stat_QC(method = "u") #EX4.1 ############################# # Example 5: np Chart # ############################# # np chart Setup ----------------------------------------------------------- set.seed(5555) bin_data <- data.frame( trial=1:30, NumNonConforming = rbinom(30, 30, prob = .50)) Units_Tested_Per_Batch <- 60 # Plot np chart ------------------------------------------------------------ EX5.1 <- ggplot(data = bin_data, aes(trial, NumNonConforming)) + geom_point() + stat_QC(method = "np", n = Units_Tested_Per_Batch) #EX5.1 ############################# # Example 6: c Chart # ############################# # c chart Setup ----------------------------------------------------------- set.seed(5555) Process1 <- data.frame(Process_run_id = 1:30, Counts=rpois(n = 30, lambda = 25), Group = "A") Process2 <- data.frame(Process_run_id = 1:30, Counts = rpois(n = 30, lambda = 5), Group = "B") all_processes <- rbind(Process1, Process2) # Plot C Chart ------------------------------------------------------------ EX6.1 <- ggplot(all_processes, aes(x=Process_run_id, y = Counts)) + geom_point() + geom_line() + stat_QC(method = "c", auto.label = TRUE, label.digits = 2) + scale_x_continuous(expand = expand_scale(mult = .25)) + facet_grid(.~Group) # EX6.1
# Load Libraries ---------------------------------------------------------- require(ggQC) 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(5556) 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) ############################# # Example 1: XmR Chart # ############################# EX1.1 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + geom_point() + geom_line() + stat_QC(method="XmR") + stat_QC_labels(method="XmR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.1 EX1.2 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") + stat_QC_labels(method="mR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.2 ############################# # Example 2: XbarR Chart # ############################# EX2.1 <- ggplot(Both_Processes, aes(x = subgroup_sample, y = metric_value, group = processID)) + stat_summary(fun.y = "mean", color = "blue", geom = c("point")) + stat_summary(fun.y = "mean", color = "blue", geom = c("line")) + stat_QC(method = "xBar.rBar") + facet_grid(.~processID, scales = "free_x") #EX2.1 EX2.2 <- ggplot(Both_Processes, aes(x = subgroup_sample, y = metric_value, group = processID)) + stat_summary(fun.y = "QCrange", color = "blue", geom = "point") + stat_summary(fun.y = "QCrange", color = "blue", geom = "line") + stat_QC(method = "rBar") + ylab("Range") + facet_grid(.~processID, scales = "free_x") #EX2.2 ############################# # Example 3: p Chart # ############################# # p chart Setup ----------------------------------------------------------- set.seed(5556) bin_data <- data.frame( trial=1:30, Num_Incomplete_Items = rpois(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 # Plot p chart ------------------------------------------------------------ EX3.1 <- ggplot(data = bin_data, aes(x=trial, y=Proportion_Incomplete, n=Num_Items_in_Set)) + geom_point() + geom_line() + stat_QC(method = "p") #EX3.1 ############################# # Example 4: u Chart # ############################# # u chart Setup ----------------------------------------------------------- set.seed(5555) bin_data <- data.frame( trial=1:30, Num_of_Blemishes = rpois(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 # Plot u chart ------------------------------------------------------------ EX4.1 <- ggplot(data = bin_data, aes(x=trial, y=Blemish_Rate, n=Num_Items_Inspected)) + geom_point() + geom_line() + stat_QC(method = "u") #EX4.1 ############################# # Example 5: np Chart # ############################# # np chart Setup ----------------------------------------------------------- set.seed(5555) bin_data <- data.frame( trial=1:30, NumNonConforming = rbinom(30, 30, prob = .50)) Units_Tested_Per_Batch <- 60 # Plot np chart ------------------------------------------------------------ EX5.1 <- ggplot(data = bin_data, aes(trial, NumNonConforming)) + geom_point() + stat_QC(method = "np", n = Units_Tested_Per_Batch) #EX5.1 ############################# # Example 6: c Chart # ############################# # c chart Setup ----------------------------------------------------------- set.seed(5555) Process1 <- data.frame(Process_run_id = 1:30, Counts=rpois(n = 30, lambda = 25), Group = "A") Process2 <- data.frame(Process_run_id = 1:30, Counts = rpois(n = 30, lambda = 5), Group = "B") all_processes <- rbind(Process1, Process2) # Plot C Chart ------------------------------------------------------------ EX6.1 <- ggplot(all_processes, aes(x=Process_run_id, y = Counts)) + geom_point() + geom_line() + stat_QC(method = "c", auto.label = TRUE, label.digits = 2) + scale_x_continuous(expand = expand_scale(mult = .25)) + facet_grid(.~Group) # EX6.1
Draws horizontal Lables on horizontal Capability lines
stat_QC_cap_hlabels(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
stat_QC_cap_hlabels(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
show |
vector, indicating which lines to draw ie., c("LCL", "LSL", "X", "USL", "UCL")
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
inherit.aes |
If |
... |
Other arguments passed on to |
horizontal lines for histogram and density plots.
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
Draws horizontal Capability Lines
stat_QC_cap_hlines(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
stat_QC_cap_hlines(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
show |
vector, indicating which lines to draw ie., c("LCL", "LSL", "X", "USL", "UCL")
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
inherit.aes |
If |
... |
Other arguments passed on to |
horizontal lines for histogram and density plots.
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
Draws horizontal Lables on horizontal Capability lines
stat_QC_cap_summary(LSL, USL, method = "xBar.rBar", px = Inf, py = -Inf, show = c("Cp", "Cpk", "Pp", "Ppk"), digits = 8, mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
stat_QC_cap_summary(LSL, USL, method = "xBar.rBar", px = Inf, py = -Inf, show = c("Cp", "Cpk", "Pp", "Ppk"), digits = 8, mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
px |
numeric, x position for table. Use Inf to force label to x-limit. |
py |
numeric, y position for table. Use Inf to force label to y-limits. May also need vjust parameter. |
show |
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.
|
digits |
integer, how many digits to report. |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
inherit.aes |
If |
... |
Other arguments passed on to |
horizontal lines for histogram and density plots.
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
Draws Vertical Lables on Vertical Capability lines
stat_QC_cap_vlabels(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
stat_QC_cap_vlabels(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
show |
vector, indicating which lines to draw ie., c("LCL", "LSL", "X", "USL", "UCL")
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
inherit.aes |
If |
... |
Other arguments passed on to |
vertical lines for histogram and density plots.
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
Draws Vertical Capability Stats
stat_QC_cap_vlines(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
stat_QC_cap_vlines(LSL, USL, method = "xBar.rBar", show = c("LSL", "USL"), mapping = NULL, data = NULL, inherit.aes = TRUE, ...)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
show |
vector, indicating which lines to draw ie., c("LCL", "LSL", "X", "USL", "UCL")
|
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
inherit.aes |
If |
... |
Other arguments passed on to |
vertical lines for histogram and density plots.
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
Generic Function for drawing QC capability information on plots
stat_QC_CAPA(LSL, USL, method = "xBar.rBar", digits = 1, mapping = NULL, data = NULL, geom = "vline", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, show = c("LSL", "USL"), direction = "v", type = NA, ...)
stat_QC_CAPA(LSL, USL, method = "xBar.rBar", digits = 1, mapping = NULL, data = NULL, geom = "vline", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, show = c("LSL", "USL"), direction = "v", type = NA, ...)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
digits |
- |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
- |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
show |
- |
direction |
- |
type |
- |
... |
Other arguments passed on to |
ggplot control charts.
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
# 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" method <- "XmR" # 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + 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_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"),#show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + facet_grid(.~ProcessID) + ylim(0,45) #EX1.2 # Facet Density Plot 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_cap_vlines(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, show=c("X", "LSL", "USL"), method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=2, size=4) + scale_x_continuous(expand = expand_scale(mult = c(0.15,.8))) + ylim(0,.5) #EX1.3 # Facet Density Plot XmR -------------------------------------------------- EX1.4 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Subgroup, color=ProcessID)) + geom_density(bw = .4, fill="grey", trim=TRUE ) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) + # geom_hline(yintercept=0, color="black") + facet_grid(.~ProcessID) + ylim(0,.5) #EX1.4 ######################################## ## Example 2: xBar.rBar or xBar.sBar ## ######################################## method <- "xBar.rBar" #Alternativly Use "xBar.sBar" if desired # Single Histogram xBar.rBar ---------------------------------------------- EX2.1 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.1 # Faceted Histogram xBar.rBar --------------------------------------------- EX2.2 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.2 # Single Density xBar.rBar ---------------------------------------------- EX2.3 <- ggplot(df[df$ProcessID==1,], aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #+ #EX2.3 # Faceted Density xBar.rBar --------------------------------------------- EX2.4 <- ggplot(df, aes(x=Value, QC.Subgroup=Subgroup)) + geom_density(bw = .4, fill="grey", alpha=.4) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8)))+ facet_grid(.~ProcessID, scales="free_x") #EX2.4 ############################### ## Example 3: xBar.rMedian ## ############################### ## Plots involving medians should give warning: "median based QC methods represent ## at best *potential* process capability" ##These plot work the same as in examples 2.X; below is an example. method <- "xBar.rMedian" EX3.1 <- ggplot(df[order(df$Process_run_id),], aes(x=Value, QC.Subgroup=Run)) + geom_histogram(binwidth = 1) + stat_QC_cap_vlines(LSL = 5, USL = 15, method=method) + stat_QC_cap_vlabels(LSL = 5, USL = 15, method=method) + stat_QC_cap_summary(LSL = 5, USL = 15, method=method, #py=.3, #show="ALL", #show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk", # "LCL", "X", "UCL", "Sig"), #show=c("Sig","TOL", "DNS"), show=c("TOL","DNS", "Cp", "Cpk", "Pp", "Ppk"), color="black", digits=4, size=4) + scale_x_continuous(expand = ggplot2::expand_scale(mult = c(0.15,.8))) #EX3.1
Draws lines, lables and summary statistics. Works best with histogram and density plots.
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)
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)
LSL |
numeric, Customer's lower specification limit |
USL |
numeric, Customer's Upper specification limit |
method |
string, calling the following methods:
|
show.lines |
vector, indicating which lines to draw ie., c("LCL", "LSL", "X", "USL", "UCL")
|
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.
|
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. |
capability layer for histogram and density plots.
for more control over lines, labels, and capability data see the following functions:
# 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
# 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
Write QC line labels to ggplot QC Charts. Useful if you want to see the value of the center line and QC limits. see method argument for methods supported.
stat_QC_labels(mapping = NULL, data = NULL, geom = "label", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, n = NULL, digits = 1, method = "xBar.rBar", color.qc_limits = "red", color.qc_center = "black", text.size = 3, physical.limits = c(NA, NA), limit.txt.label = c("LCL", "UCL"), ...)
stat_QC_labels(mapping = NULL, data = NULL, geom = "label", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, n = NULL, digits = 1, method = "xBar.rBar", color.qc_limits = "red", color.qc_center = "black", text.size = 3, physical.limits = c(NA, NA), limit.txt.label = c("LCL", "UCL"), ...)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
n |
number, for
|
digits |
integer, indicating the number of decimal places |
method |
string, calling the following methods:
|
color.qc_limits |
color, used to colorize the plot's upper and lower mR control limits. |
color.qc_center |
color, used to colorize the plot's center line. |
text.size |
number, size of the text label |
physical.limits |
vector, specify lower physical boundary and upper physical boundary |
limit.txt.label |
vector, provides option for naming or not showing the limit text labels (e.g., UCL, LCL)
|
... |
Other arguments passed on to |
data need to produce the mR plot in ggplot.
######################### # Example 1: mR Chart # ######################### # Load Libraries ---------------------------------------------------------- require(ggQC) 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(5556) 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) # Facet Plot - Both Processes --------------------------------------------- EX1.1 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + geom_point() + geom_line() + stat_QC(method="XmR") + stat_QC_labels(method="XmR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.1 EX1.2 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") + stat_QC_labels(method="mR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.2 ############################# # Example 2: XbarR Chart # ############################# # Facet Plot - Studentized Process ---------------------------------------- EX2.1 <- ggplot(Both_Processes, aes(x=subgroup_sample, y = metric_value, group = processID)) + geom_point(alpha=.2) + stat_summary(fun.y = "mean", color="blue", geom=c("point")) + stat_summary(fun.y = "mean", color="blue", geom=c("line")) + stat_QC() + facet_grid(.~processID, scales = "free_x") + stat_QC_labels(text.size =3, label.size=.1) #EX2.1 EX2.2 <- ggplot(Both_Processes, aes(x=subgroup_sample, y = metric_value, group = processID)) + stat_summary(fun.y = "QCrange", color="blue", geom = "point") + stat_summary(fun.y = "QCrange", color="blue", geom = "line") + stat_QC(method="rBar") + stat_QC_labels(digits=2, method="rBar") + ylab("Range") + facet_grid(.~processID, scales = "free_x") #EX2.2
######################### # Example 1: mR Chart # ######################### # Load Libraries ---------------------------------------------------------- require(ggQC) 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(5556) 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) # Facet Plot - Both Processes --------------------------------------------- EX1.1 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + geom_point() + geom_line() + stat_QC(method="XmR") + stat_QC_labels(method="XmR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.1 EX1.2 <- ggplot(Both_Processes, aes(x=Process_run_id, y = metric_value)) + stat_mR() + ylab("Moving Range") + stat_QC_labels(method="mR", digits = 2) + facet_grid(.~processID, scales = "free_x") #EX1.2 ############################# # Example 2: XbarR Chart # ############################# # Facet Plot - Studentized Process ---------------------------------------- EX2.1 <- ggplot(Both_Processes, aes(x=subgroup_sample, y = metric_value, group = processID)) + geom_point(alpha=.2) + stat_summary(fun.y = "mean", color="blue", geom=c("point")) + stat_summary(fun.y = "mean", color="blue", geom=c("line")) + stat_QC() + facet_grid(.~processID, scales = "free_x") + stat_QC_labels(text.size =3, label.size=.1) #EX2.1 EX2.2 <- ggplot(Both_Processes, aes(x=subgroup_sample, y = metric_value, group = processID)) + stat_summary(fun.y = "QCrange", color="blue", geom = "point") + stat_summary(fun.y = "QCrange", color="blue", geom = "line") + stat_QC(method="rBar") + stat_QC_labels(digits=2, method="rBar") + ylab("Range") + facet_grid(.~processID, scales = "free_x") #EX2.2
ggplot stat function that renders a faceted plot of QC violations 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
stat_qc_violations(mapping = NULL, data = NULL, geom = "point", position = "identity", show.legend = NA, inherit.aes = TRUE, na.rm = FALSE, method = "xBar.rBar", geom_points = TRUE, geom_line = TRUE, point.size = 1.5, point.color = "black", violation_point.color = "red", line.color = NULL, rule.color = "darkgreen", show.facets = c(1:4), ...)
stat_qc_violations(mapping = NULL, data = NULL, geom = "point", position = "identity", show.legend = NA, inherit.aes = TRUE, na.rm = FALSE, method = "xBar.rBar", geom_points = TRUE, geom_line = TRUE, point.size = 1.5, point.color = "black", violation_point.color = "red", line.color = NULL, rule.color = "darkgreen", show.facets = c(1:4), ...)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use display the data |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
method |
string, calling the following methods:
|
geom_points |
boolean, draw points |
geom_line |
boolean, draw line |
point.size |
number, size of points on chart |
point.color |
string, color of points on charts (e.g., "black") |
violation_point.color |
string, color of violation points on charts (e.g., "red") |
line.color |
string, color of lines connecting points |
rule.color |
string, color or horizontal rules indicating distribution center and sigma levels |
show.facets |
vector, selects violation facet 1 through 4. eg., c(1:4), c(1,4) |
... |
Other arguments passed on to |
faceted plot.
##################################### # Example 1: XmR Check Violations # ##################################### # Load Libraries ---------------------------------------------------------- require(ggQC) require(ggplot2) # 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 ) # Render QC Violation Plot ------------------------------------------------------ EX1 <- ggplot(QC_XmR, aes(x = Run_Order, y = data)) + stat_qc_violations(method = "XmR") #Makes facet graph with violations #EX1 ####################################### # 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") # Render QC Violation Plot -------------------------------------------------- EX2 <- ggplot(QC_xBar.rBar, aes(x = sub_group, y = value)) + stat_qc_violations(method = "xBar.rBar") #stat_qc_violations(method="xBar.rMedian") #stat_qc_violations(method="xBar.sBar") #stat_qc_violations(method="xMedian.rBar") #stat_qc_violations(method="xMedian.rMedian") #EX2 ####################################### # Example 3: Selected Facets # ####################################### # Render QC Violation Plot -------------------------------------------------- EX3 <- ggplot(QC_xBar.rBar, aes(x = sub_group, y = value)) + stat_qc_violations(method = "xBar.rBar", show.facets = c(4)) #EX3 ####################################################### # Complete User Control - Bypass stat_qc_violation # ####################################################### #### The code below has two options if you are looking for complete #### control over the look and feel of the graph. Use option 1 or option #### 2 as appropriate. If you want something quick and easy use examples above. ##### Option 1: Setup for XmR Type Data # QC_XmR: Defined in Example 1 QC_Vs <- QC_Violations(data = QC_XmR$data, method = "XmR") QC_Stats <- QC_Lines(data = QC_XmR$data, method = "XmR") MEAN <- QC_Stats$mean SIGMA <- QC_Stats$sigma ##### Option 2: Setup for xBar.rBar Type Data # QC_xBar.rBar: Defined in Example 2 QC_Vs <- QC_Violations(data = QC_xBar.rBar, formula = value~sub_group, method = "xBar.rBar") QC_Stats <- QC_Lines(data = QC_xBar.rBar, formula = value~sub_group, method = "xBar.rBar") MEAN <- QC_Stats$xBar_Bar SIGMA <- QC_Stats$sigma ##### Setup second table for horizontal rules FacetNames <- c("Violation Same Side", "Violation 1 Sigma", "Violation 2 Sigma", "Violation 3 Sigma") QC_Vs$Violation_Result <- ordered(QC_Vs$Violation_Result, levels=FacetNames) QC_Stats_df <- data.frame( Violation_Result = factor(x = FacetNames, levels = FacetNames), SigmaPlus = MEAN+SIGMA*0:3, MEAN = MEAN, SigmaMinus = MEAN-SIGMA*0:3 ) ##### Make the Plot ggplot(QC_Vs, aes(x=Index, y=data, color=Violation, group=1)) + geom_point() + geom_line() + facet_grid(.~Violation_Result) + geom_hline(data = QC_Stats_df, aes(yintercept = c(SigmaPlus))) + geom_hline(data = QC_Stats_df, aes(yintercept = c(SigmaMinus))) + geom_hline(data = QC_Stats_df, aes(yintercept = c(MEAN)))
##################################### # Example 1: XmR Check Violations # ##################################### # Load Libraries ---------------------------------------------------------- require(ggQC) require(ggplot2) # 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 ) # Render QC Violation Plot ------------------------------------------------------ EX1 <- ggplot(QC_XmR, aes(x = Run_Order, y = data)) + stat_qc_violations(method = "XmR") #Makes facet graph with violations #EX1 ####################################### # 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") # Render QC Violation Plot -------------------------------------------------- EX2 <- ggplot(QC_xBar.rBar, aes(x = sub_group, y = value)) + stat_qc_violations(method = "xBar.rBar") #stat_qc_violations(method="xBar.rMedian") #stat_qc_violations(method="xBar.sBar") #stat_qc_violations(method="xMedian.rBar") #stat_qc_violations(method="xMedian.rMedian") #EX2 ####################################### # Example 3: Selected Facets # ####################################### # Render QC Violation Plot -------------------------------------------------- EX3 <- ggplot(QC_xBar.rBar, aes(x = sub_group, y = value)) + stat_qc_violations(method = "xBar.rBar", show.facets = c(4)) #EX3 ####################################################### # Complete User Control - Bypass stat_qc_violation # ####################################################### #### The code below has two options if you are looking for complete #### control over the look and feel of the graph. Use option 1 or option #### 2 as appropriate. If you want something quick and easy use examples above. ##### Option 1: Setup for XmR Type Data # QC_XmR: Defined in Example 1 QC_Vs <- QC_Violations(data = QC_XmR$data, method = "XmR") QC_Stats <- QC_Lines(data = QC_XmR$data, method = "XmR") MEAN <- QC_Stats$mean SIGMA <- QC_Stats$sigma ##### Option 2: Setup for xBar.rBar Type Data # QC_xBar.rBar: Defined in Example 2 QC_Vs <- QC_Violations(data = QC_xBar.rBar, formula = value~sub_group, method = "xBar.rBar") QC_Stats <- QC_Lines(data = QC_xBar.rBar, formula = value~sub_group, method = "xBar.rBar") MEAN <- QC_Stats$xBar_Bar SIGMA <- QC_Stats$sigma ##### Setup second table for horizontal rules FacetNames <- c("Violation Same Side", "Violation 1 Sigma", "Violation 2 Sigma", "Violation 3 Sigma") QC_Vs$Violation_Result <- ordered(QC_Vs$Violation_Result, levels=FacetNames) QC_Stats_df <- data.frame( Violation_Result = factor(x = FacetNames, levels = FacetNames), SigmaPlus = MEAN+SIGMA*0:3, MEAN = MEAN, SigmaMinus = MEAN-SIGMA*0:3 ) ##### Make the Plot ggplot(QC_Vs, aes(x=Index, y=data, color=Violation, group=1)) + geom_point() + geom_line() + facet_grid(.~Violation_Result) + geom_hline(data = QC_Stats_df, aes(yintercept = c(SigmaPlus))) + geom_hline(data = QC_Stats_df, aes(yintercept = c(SigmaMinus))) + geom_hline(data = QC_Stats_df, aes(yintercept = c(MEAN)))
Calculates overall mean rate for count data acquired over a variable area of opportunity.
uBar(y, n, na.rm = FALSE, ...)
uBar(y, n, na.rm = FALSE, ...)
y |
Vector of counts per unit opportunity (rate). Observations may have a different area of opportunity, n. |
n |
A vector representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A vector of mean rate, length equal to length of parameter y.
set.seed(5555) counts <- rpois(100, 25) n <- rpois(100, 15) uBar(y = counts / n, n = n)
set.seed(5555) counts <- rpois(100, 25) n <- rpois(100, 15) uBar(y = counts / n, n = n)
Calculates point-wise lower control limit (LCL) for count data acquired over a variable area of opportunity.
uBar_LCL(y, n, na.rm = FALSE, ...)
uBar_LCL(y, n, na.rm = FALSE, ...)
y |
Vector of counts per unit opportunity (rate). Observations may have a different area of opportunity, n. |
n |
A vector representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A vector; point-wise 3-sigma lower control limit (LCL)
set.seed(5555) counts <- rpois(100, 25) n <- rpois(100, 15) uBar_LCL(y = counts / n, n = n)
set.seed(5555) counts <- rpois(100, 25) n <- rpois(100, 15) uBar_LCL(y = counts / n, n = n)
Calculates point-wise upper control limit (UCL) for count data acquired over a variable area of opportunity.
uBar_UCL(y, n, na.rm = FALSE, ...)
uBar_UCL(y, n, na.rm = FALSE, ...)
y |
Vector of counts per unit opportunity (rate). Observations may have a different area of opportunity, n. |
n |
A vector representing the area of opportunity. |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A vector; point-wise 3-sigma upper control limit (UCL)
set.seed(5555) counts <- rpois(100, 25) n <- rpois(100, 15) uBar_UCL(y = counts / n, n = n)
set.seed(5555) counts <- rpois(100, 25) n <- rpois(100, 15) uBar_UCL(y = counts / n, n = n)
function to calculate a standardized distance to the Upper specification limit (sigma units)
UD(LSL, USL, QC.Center, QC.Sigma)
UD(LSL, USL, QC.Center, QC.Sigma)
LSL |
number, customer's lower specification limit. |
USL |
number, customer's upper specification limit. |
QC.Center |
number, the mean or median value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
QC.Sigma |
number, the sigma value determined from an XmR plot or a Studentized (e.g., xBar) analysis. |
numeric, standardized distance to the upper specification limit (sigma units)
Calculates the mean subgroup means used when constructing a xBar-R or xBar-S charts.
xBar_Bar(data, value, grouping, formula = NULL, ...)
xBar_Bar(data, value, grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean of subgroup means.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_Bar(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_Bar(data = df, formula = v~g)
Calculates the xBar_One LCL used when constructing a xBar-One chart.
xBar_one_LCL(y, na.rm = FALSE, ...)
xBar_one_LCL(y, na.rm = FALSE, ...)
y |
Vector of values |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; xBar_One Lower Control Limit (LCL)
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) xBar_one_LCL(values)
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) xBar_one_LCL(values)
Calculates the xBar_One UCL used when constructing a xBar-One chart.
xBar_one_UCL(y, na.rm = FALSE, ...)
xBar_one_UCL(y, na.rm = FALSE, ...)
y |
Vector of values |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
... |
further arguments passed to or from other methods. |
A number; xBar_One Upper Control Limit (UCL)
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) xBar_one_UCL(values)
set.seed(5555) values <- rnorm(n = 100, mean = 25, sd = 1) xBar_one_UCL(values)
Calculates the mean of subgroup means lower control limit used when constructing a xBar-R charts.
xBar_rBar_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xBar_rBar_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means lower control limit.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rBar_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rBar_LCL(data = df, formula = v~g)
Calculates the mean of subgroup means upper control limit used when constructing a xBar-R charts.
xBar_rBar_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xBar_rBar_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means upper control limit.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rBar_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rBar_UCL(data = df, formula = v~g)
Calculates the mean of subgroup means lower control limit based on the median range. The result is used when constructing a xBar-rMedian charts.
xBar_rMedian_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xBar_rMedian_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means Lower Control Limit (LCL) based on Median Range
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rMedian_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rMedian_LCL(data = df, formula = v~g)
Calculates the mean of subgroup means upper control limit based on the median range. The result is used when constructing a xBar-rMedian charts.
xBar_rMedian_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xBar_rMedian_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means Upper Control Limit (UCL) based on Median Range
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rMedian_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rMedian_UCL(data = df, formula = v~g)
Calculates the mean of subgroup means lower control limit based on the standard deviation. The result is used when constructing a xBar-S charts.
xBar_sBar_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xBar_sBar_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means Lower Control Limit (LCL) based on standard deviation
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_sBar_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_sBar_LCL(data = df, formula = v~g)
Calculates the mean of subgroup means upper control limit based on the standard deviation. The result is used when constructing a xBar-S charts.
xBar_sBar_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xBar_sBar_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means Upper Control Limit (UCL) based on standard deviation
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_sBar_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_sBar_UCL(data = df, formula = v~g)
Calculates the mean of subgroup medians used when constructing a xMedian-R charts.
xMedian_Bar(data, value, grouping, formula = NULL, ...)
xMedian_Bar(data, value, grouping, formula = NULL, ...)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
formula |
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 |
... |
further arguments passed to or from other methods. |
A number; mean of subgroup medians.
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_Bar(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_Bar(data = df, formula = v~g)
Calculates the mean of subgroup medians lower control limit based on the mean range. The result is used when constructing a xMedian-R charts.
xMedian_rBar_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xMedian_rBar_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup medians Lower Control Limit (LCL) based on mean range
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rMedian_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xBar_rMedian_LCL(data = df, formula = v~g)
Calculates the mean of subgroup medians upper control limit based on the mean subgroup range. The result is used when constructing a xMedian-R charts.
xMedian_rBar_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xMedian_rBar_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup means Upper Control Limit (UCL) based on Median Range
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_rBar_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_rBar_UCL(data = df, formula = v~g)
Calculates the mean of subgroup medians lower control limit based on the median subgroup range. The result is used when constructing a xMedian-rMedian charts.
xMedian_rMedian_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xMedian_rMedian_LCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup median Lower Control Limit (LCL) based on Median Range
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_rMedian_LCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_rMedian_LCL(data = df, formula = v~g)
Calculates the mean of subgroup medians upper control limit based on the median subgroup range. The result is used when constructing a xMedian-rMedian charts.
xMedian_rMedian_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
xMedian_rMedian_UCL(data, value, grouping, n = NULL, natural = F, formula = NULL)
data |
data frame to be processed |
value |
numeric vector in a data frame with values of interest. |
grouping |
single factor/variable to split the data frame "values" by. |
n |
a number indicating a hypothetical subgroup size other than, function determined subgroup n determined by the floor length of subgroup values. |
natural |
logical, if TRUE calculate limits for individuals (n=1) else calculate for n determined by the floor length of subgroup values |
formula |
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 |
A number; mean of subgroup median upper Control Limit (UCL) based on Median Range
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_rMedian_UCL(data = df, formula = v~g)
set.seed(5555) df <- data.frame(v=rnorm(60, 0, 1), g=rep(c("A","B","C","D","E"), each=12)) xMedian_rMedian_UCL(data = df, formula = v~g)