tcc: Trellis Control Charts

Description Usage Arguments Details Value References Examples

View source: R/tcc.R

Description

Run and control charts for multivariate data i trellis (grid) layout.

Usage

1
2
3
4
5
6
7
tcc(n, d, x, g1, g2, breaks, notes, data, chart = c("run", "i", "mr", "xbar",
  "s", "t", "p", "c", "u", "g"), multiply = 1, freeze = NULL, exclude,
  target = NA, n.sum = FALSE, y.neg = TRUE, y.percent = FALSE,
  y.expand = NULL, x.pad = 1, x.date.format = NULL, cl.lab = TRUE,
  cl.decimals = NULL, main, xlab = "Subgroup", ylab = "Value",
  subtitle = NULL, caption = NULL, cex = 1, pex = 1, prime = TRUE,
  flip = FALSE, dots.only = FALSE, print.summary = FALSE, ...)

Arguments

n

Numerator, numeric vector of counts or measures to plot. Mandatory.

d

Denominator, numeric vector of subgroup sizes. Mandatory for P and U charts.

x

Subgrouping vector used for aggregating data by subgroup and making x-labels. Mandatory for Xbar and S charts.

g1

Grouping vector 1 used for trellis layout (facets).

g2

Grouping vector 2 used for trellis layout (facets).

breaks

Numeric vector of break points. Useful for splitting graph in two or more sections with separate center line and control limits.

notes

Character vector of notes to be added to individual. data points.

data

Data frame containing variables.

chart

Type of control chart. Possible types are:

  • "run": run chart (default).

  • "i": individuals chart.

  • "mr": moving range chart.

  • "xbar": sample average chart.

  • "s": sample standard deviation chart.

  • "t": time between events chart.

  • "p": proportions chart.

  • "c": counts chart.

  • "u": rates chart.

  • "g": cases between events chart.

multiply

Integer indicating a number to multiply y axis by, e.g. 100 for percents rather than proportions. See also y.percent argument.

freeze

Number identifying the last data point to include in calculations of center and limits (ignored if breaks argument is given).

exclude

Numeric vector of data points to exclude from runs analysis and calculations of center and control lines (same for each facet).

target

Numeric value indicating a target value to be plotted as a horizontal line (same for each facet).

n.sum

Logical value indicating whether the mean (default) or sum of numerator (n argument) per subgroup should be plotted. Only relevant for run, C, and I charts with multiple counts per subgroup.

y.neg

Logical value. If TRUE (default), the y axis is allowed to be negative (only relevant for I and Xbar charts).

y.percent

Logical. If TRUE, formats y axis labels as percent.

y.expand

Numeric value to include in y axis. Useful e.g. for beginning y axis at zero.

x.pad

Number indicating expansion of x axis to make room for center line labels.

x.date.format

Date format of x axis labels. See ?strftime() for possible date formats.

cl.lab

Logical value. If TRUE (default), plots center line labels.

cl.decimals

Number of decimals on center line labels.

main

Character string specifying the title of the plot.

xlab

Character string specifying the x axis label.

ylab

Character string specifying the y axis label.

subtitle

Character string specifying the subtitle.

caption

Character string specifying the caption.

cex

Number indicating the amount by which text should be magnified.

pex

Number indicating the amount by which plotting symbols should be magnified.

prime

Logical value, If TRUE (default unless dots.only = TRUE), control limits incorporate between-subgroup variation as proposed by Laney (2002). Only relevant for P and U charts.

flip

Logical. If TRUE rotates the plot 90 degrees.

dots.only

Logical value. If TRUE, data points are not connected by lines, prime is forced to be FALSE, and runs analysis is not performed. Useful for comparison and funnel plots.

print.summary

Logical. If TRUE, prints summary of tcc object.

...

Further arguments to ggplot function.

Details

tcc() is a wrapper function for ggplot2() that makes multivariate run and control charts. It takes up to two grouping variables for multidimensional trellis plots.

Note that, in contrast to the qic() function, the prime argument defaults to TRUE, which means that control limits of P and U charts by default incorporate between-subgroup variation as proposed by Laney (2002).

Value

An object of class ggplot.

References

Runs analysis:

Calculation of control limits:

Examples

 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
# Run chart of 24 random normal variables
tcc(rnorm(24))

# Build data frame for examples
d <- data.frame(x = rep(1:24, 4),
                mo = (rep(seq(as.Date('2014-1-1'),
                              length.out = 24,
                              by = 'month'),
                          4)),
                n = rbinom(4 * 24, 100, 0.5),
                d = round(runif(4 * 24, 90, 110)),
                g1 = rep(c('a', 'b'), each = 48),
                g2 = rep(c('A', 'B'), each = 24))

# Run chart with two grouping variables
tcc(n, d, mo, g1 = g1, g2 = g2, data = d)

# P chart
tcc(n, d, mo, g1 = g1, g2 = g2, data = d, chart = 'p')

# P chart with baseline fixed to the first 12 data points
tcc(n, d, mo, g1 = g1, g2 = g2, data = d, chart = 'p', freeze = 12)

# P chart with two breaks and summary output
tcc(n, d, mo, g1 = g1, g2 = g2, data = d, chart = 'p',
 breaks = c(12, 18), print.summary = TRUE)

anhoej/qicharts documentation built on Aug. 30, 2017, 9:08 a.m.