Functions for making run charts and basic Shewhart control charts for measure and count data. The main function, qic(), creates run and control charts and has a simple interface with a rich set of options to control data analysis and plotting, including options for automatic data aggregation by subgroups, easy analysis of before-and-after data, exclusion of one or more data points from analysis, and splitting charts into sequential time periods. Missing values and empty subgroups are handled gracefully.
library(qicharts)
## qicharts will no longer be maintained. Please consider moving to qicharts2: https://anhoej.github.io/qicharts2/.
# Build data frame for examples
df <- data.frame(x = rep(1:24, 4),
ReportMonth = (rep(seq(as.Date('2014-1-1'),
length.out = 24,
by = 'month'),
4)),
num = rbinom(4 * 24, 100, 0.5),
denom = round(runif(4 * 24, 90, 110)),
grp1 = rep(c('g', 'h'), each = 48),
grp2 = rep(c('A', 'B'), each = 24))
# Run chart with two grouping variables
tcc(num, denom, ReportMonth, g1 = grp1, g2 = grp2, data = df, main = "Trellis Run Chart")
# C chart
tcc(num, denom, ReportMonth, g1 = grp1, g2 = grp2, data = df, chart = 'c',
main ="Trellis C chart")
tcc(num, denom, ReportMonth, g1 = grp1, data = df, chart = 'p',
main ="Trellis P chart , 1 facet")
# P chart
tcc(num, denom, ReportMonth, g1 = grp1, g2 = grp2, data = df, chart = 'p',
main ="Trellis P chart")
# P chart with baseline fixed to the first 9 data points
tcc(num, denom, ReportMonth, g1 = grp1, g2 = grp2, data = df, chart = 'p', freeze = 9,
main = "Trellis P chart with limits fixed to first 9 data points")
# U chart with two breaks and summary output
tcc(num, denom, ReportMonth, g1 = grp1, g2 = grp2, data = df, chart = 'u',
breaks = c(9, 15), main =" Trellis U chart with multiple breaks",
print.summary = TRUE)
## g1 g2 breaks n.obs n.useful cl lcl ucl limits.signal
## 1 g A 1 9 9 0.4983278 0.3446821 0.6519734 FALSE
## 2 g A 2 6 6 0.4894992 0.3777799 0.6012185 FALSE
## 3 g A 3 9 9 0.5535098 0.3557399 0.7512797 FALSE
## 4 g B 1 9 9 0.4945770 0.3926926 0.5964614 FALSE
## 5 g B 2 6 6 0.4784854 0.1899938 0.7669769 FALSE
## 6 g B 3 9 9 0.4934066 0.2877937 0.6990194 FALSE
## 7 h A 1 9 9 0.4918919 0.2326361 0.7511477 FALSE
## 8 h A 2 6 6 0.5270936 0.3815084 0.6726788 FALSE
## 9 h A 3 9 9 0.4783092 0.3128201 0.6437984 FALSE
## 10 h B 1 9 9 0.5376593 0.4510682 0.6242505 FALSE
## 11 h B 2 6 6 0.5140496 0.3500096 0.6780896 FALSE
## 12 h B 3 9 9 0.4977273 0.3088906 0.6865640 FALSE
## runs.signal longest.run longest.run.max n.crossings n.crossings.min
## 1 FALSE 4 6 3 2
## 2 FALSE 2 6 4 1
## 3 FALSE 3 6 3 2
## 4 FALSE 4 6 4 2
## 5 FALSE 2 6 4 1
## 6 FALSE 3 6 4 2
## 7 FALSE 1 6 8 2
## 8 FALSE 2 6 3 1
## 9 FALSE 5 6 2 2
## 10 FALSE 5 6 3 2
## 11 FALSE 4 6 2 1
## 12 FALSE 6 6 3 2