stat_mR {ggQC} | R Documentation |
Generate mR chart in ggplot
Description
ggplot stat used to create a mR chart in ggplot
Usage
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", ...)
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. |
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 |
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)
# 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")