Description Usage Arguments Value Examples
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
1 2 3 4 5 6 7 8 | 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | # 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.