stat_QC_labels {ggQC} | R Documentation |
Write QC Line Labels to ggplot QC Charts.
Description
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.
Usage
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"), ...)
Arguments
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 |
Value
data need to produce the mR plot in ggplot.
Examples
#########################
# 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