### Install qcc from GitHub Source: https://github.com/luca-scr/qcc/blob/master/docs/index.html Installs the development version of the qcc package directly from GitHub. This requires the 'devtools' package and allows for building with specific options. ```R # install.packages("devtools") devtools::install_github("luca-scr/qcc", build = TRUE, build_opts = c("--no-resave-data", "--no-manual")) ``` -------------------------------- ### Load qcc Package and Display Version Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html This snippet demonstrates how to load the qcc R package and displays its version information and citation details. It's a common starting point for using the package's functionalities. ```R library(qcc) ## __ _ ___ ___ ## / _ |/ __/ __| ## | (_| | (_| (__ ## \__ |\___\___| ## |_| version 3.0 ## Type 'citation("qcc")' for citing this R package in publications. ``` -------------------------------- ### Install qcc from GitHub Source: https://github.com/luca-scr/qcc/blob/master/README.md Installs the development version of the qcc package directly from GitHub. This requires the devtools package and may include the latest features or bug fixes. ```r # install.packages("devtools") devtools::install_github("luca-scr/qcc", build = TRUE, build_opts = c("--no-resave-data", "--no-manual")) ``` -------------------------------- ### Add example for warning limits in qcc man page Source: https://github.com/luca-scr/qcc/blob/master/docs/news/index.html qcc version 2.6 includes an example in its man page demonstrating how to add warning limits to control charts. ```R qcc(..., warning.limits = c(lower_warning, upper_warning)) ``` -------------------------------- ### Install qcc from CRAN Source: https://github.com/luca-scr/qcc/blob/master/README.md Installs the stable version of the qcc package from the Comprehensive R Archive Network (CRAN). This is the recommended method for most users. ```r install.packages("qcc") ``` -------------------------------- ### Example: Process Capability Calculation and Display Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/processCapability.html Demonstrates how to use the `processCapability` function with sample data. It first creates an 'xbar' qcc object and then computes and displays the process capability indices. ```R data(pistonrings) diameter = qccGroups(data = pistonrings, diameter, sample) q = qcc(diameter[1:25,], type="xbar", nsigmas=3) pc = processCapability(q, spec.limits=c(73.95,74.05)) pc ``` -------------------------------- ### Install qcc from CRAN Source: https://github.com/luca-scr/qcc/blob/master/docs/index.html Installs the released version of the qcc package from the Comprehensive R Archive Network (CRAN). This is the standard method for installing stable package versions. ```R install.packages("qcc") ``` -------------------------------- ### Load and Describe pcmanufact Dataset (R) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/pcmanufact.html This snippet demonstrates how to load the 'pcmanufact' dataset and then use the 'describe' function to get summary statistics for the 'x' (nonconformities) and 'size' (inspected units) variables. It also shows how to transform the data and create a basic plot. ```R data(pcmanufact) describe(pcmanufact) #> Obs Mean StdDev Min Median Max #> x 20 9.65 3.133 5 10 16 #> size 20 5.00 0.000 5 5 5 pcmanufact = transform(pcmanufact, sample = seq(nrow(pcmanufact))) plot(x/size ~ sample, data = pcmanufact, type="b") ``` -------------------------------- ### Add warning limits to control charts Source: https://github.com/luca-scr/qcc/blob/master/NEWS.md An example demonstrating how to add warning limits to control charts has been included in the qcc man page starting from version 2.6. ```R # Example usage in qcc man page ``` -------------------------------- ### View qcc Vignette Source: https://github.com/luca-scr/qcc/blob/master/docs/index.html Opens the vignette for the qcc package, which provides a detailed tour of its functionalities and usage examples. This is a great resource for learning how to use the package. ```R vignette("qcc") ``` -------------------------------- ### View qcc Vignette Source: https://github.com/luca-scr/qcc/blob/master/README.md Opens the vignette for the qcc package, providing a detailed guide on its usage and examples. This is useful for understanding the package's capabilities and how to apply them. ```r vignette("qcc") ``` -------------------------------- ### Create U Chart with R qcc Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates a U quality control chart using the qcc function from the R qcc package. This example shows how to create the chart with specified data, sample sizes, and labels, including new data for phase II analysis. ```R data(circuit) (q = with(circuit, qcc(x[inc], sizes = size[inc], type = "u", labels = inc, newdata = x[!trial], newsizes = size[!trial], newlabels = which(!trial)))) plot(q) ``` -------------------------------- ### Create T2 Chart with Subgrouped Data Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/mqcc.html This example demonstrates how to create a multivariate T2 quality control chart using subgrouped data. It shows the basic usage of the `mqcc` function with the `RyanMultivar` dataset and visualizes the chart using `ellipseChart`. It also illustrates how to generate summary statistics for the created chart. ```R data(RyanMultivar) str(RyanMultivar) q = mqcc(RyanMultivar, type = "T2") summary(q) ellipseChart(q) ellipseChart(q, show.id = TRUE) ``` -------------------------------- ### CUSUM Chart for Grouped Data (Phase I and II) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/cusum.html This example shows how to use the 'cusum' function for both phase I and phase II analysis with grouped data. It first establishes the control limits using phase I data and then applies them to new phase II data, plotting the results. ```R q = cusum(diameter[1:25,], newdata=diameter[26:40,]) summary(q) plot(q, chart.all=FALSE) ``` -------------------------------- ### Load and Describe Antifreeze Data in R Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/antifreeze.html This snippet demonstrates how to load the 'antifreeze' dataset and use the 'describe' function to get summary statistics for the water content of antifreeze batches. ```R data(antifreeze) describe(antifreeze) #> Obs Mean StdDev Min Median Max #> antifreeze 34 2.57 0.22 2.17 2.55 3 ``` -------------------------------- ### Create Shewhart xbar Chart (One-at-Time Data) with qcc Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/stats.xbar.one.html Demonstrates how to use the `qcc` function in R to create a Shewhart xbar chart for one-at-time data. It shows examples using both 'MR' (moving range) and 'SD' (sample standard deviation) methods for estimating the process standard deviation. ```R # Water content of antifreeze data (Wetherill and Brown, 1991, p. 120) x = c(2.23, 2.53, 2.62, 2.63, 2.58, 2.44, 2.49, 2.34, 2.95, 2.54, 2.60, 2.45, 2.17, 2.58, 2.57, 2.44, 2.38, 2.23, 2.23, 2.54, 2.66, 2.84, 2.81, 2.39, 2.56, 2.70, 3.00, 2.81, 2.77, 2.89, 2.54, 2.98, 2.35, 2.53) # the Shewhart control chart for one-at-time data # 1) using MR (default) qcc(x, type="xbar.one", data.name="Water content (in ppm) of batches of antifreeze") #> ── Quality Control Chart ───────────────────────── #> #> Chart type = xbar.one #> Data (phase I) = x #> Number of groups = 34 #> Group sample size = 1 #> Center of group statistics = 2.569706 #> Standard deviation = 0.1794541 #> #> Control limits at nsigmas = 3 #> LCL UCL #> 2.031344 3.108068 # 2) using SD qcc(x, type="xbar.one", std.dev = "SD", data.name="Water content (in ppm) of batches of antifreeze") #> ── Quality Control Chart ───────────────────────── #> #> Chart type = xbar.one #> Data (phase I) = x #> Number of groups = 34 #> Group sample size = 1 #> Center of group statistics = 2.569706 #> Standard deviation = 0.2216795 #> #> Control limits at nsigmas = 3 #> LCL UCL #> 1.904667 3.234744 ``` -------------------------------- ### Load Circuit Data Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/circuit.html Loads the 'circuit' dataset into the R environment. This dataset contains observations on sample number, number of defectives, sample size, and a trial indicator. ```R data(circuit) ``` -------------------------------- ### Set or Return qcc Options (qcc) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/index.html Allows setting or retrieving global options for the qcc package, controlling default behaviors and parameters. ```R qcc.options() ``` -------------------------------- ### R Session Information Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Provides detailed information about the R environment, including version, platform, locale, attached packages, and loaded namespaces. This is useful for ensuring reproducibility of the analysis. ```R sessionInfo() ``` -------------------------------- ### Multivariate T2 Chart for Ryan Data Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Creates a multivariate T2 control chart for monitoring processes with multiple correlated variables. This example uses the 'mqcc' function from the 'qcc' package with the 'RyanMultivar' dataset, which contains p=2 variables and m=20 samples. ```R data(RyanMultivar) (q <- mqcc(RyanMultivar, type = "T2")) plot(q) ``` -------------------------------- ### R: Set and retrieve qcc package options Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/qcc.options.html Demonstrates how to save default options, retrieve a specific option, change parameters like 'cex.stats' and 'bg.margin', update list-based options for 'violating.runs' and 'beyond.limits', apply these settings to a qcc chart, and finally restore the original default options. ```R old = qcc.options() # save defaults qcc.options("cex.stats") # get a single parameter #> [1] 0.9 qcc.options("cex.stats"=1.2) # change parameters qcc.options(bg.margin="azure2") qcc.options("violating.runs" = list(pch = 15, col = "purple")) qcc.options("beyond.limits" = list(pch = 15, col = "orangered")) qcc(rnorm(100), type = "xbar.one", std.dev = 0.7) # see the results #> ── Quality Control Chart ───────────────────────── #> #> Chart type = xbar.one #> Data (phase I) = rnorm(100) #> Number of groups = 100 #> Group sample size = 1 #> Center of group statistics = 0.208416 #> Standard deviation = 0.7 #> #> Control limits at nsigmas = 3 #> LCL UCL #> -1.891584 2.308416 qcc.options(old) # restore old defaults ``` -------------------------------- ### EWMA Chart with Viscosity Data Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/ewma.html This example shows how to generate an EWMA control chart using the 'viscosity' dataset. It separates the data into 'trial' (phase I) and 'non-trial' (phase II) observations and applies the EWMA function with specific lambda and nsigmas values. ```R data(viscosity) q = with(viscosity, ewma(viscosity[trial], lambda = 0.2, nsigmas = 2.7, newdata = viscosity[!trial])) summary(q) plot(q) ``` -------------------------------- ### Creating Cusum Charts with QCC Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Demonstrates the creation of Cumulative Sum (Cusum) charts using the QCC package in R. It covers both phase I analysis (establishing control limits from historical data) and phase II analysis (monitoring new data against established limits), including setting decision intervals and shift detection parameters. ```R data(pistonrings) diameter <- qccGroups(diameter, sample, data = pistonrings) (q = cusum(diameter[1:25,], decision.interval = 4, se.shift = 1)) plot(q) ``` ```R (q <- cusum(diameter[1:25,], newdata = diameter[26:40,])) plot(q) plot(q, chart.all = FALSE) plot(q, xtime = seq(Sys.Date() - nrow(diameter)+1, Sys.Date(), by = 1), add.stats = FALSE) + scale_x_date(date_breaks = "4 days", date_labels = "%d-%b") ``` -------------------------------- ### Load and Describe Viscosity Data by Trial Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/viscosity.html This R code snippet demonstrates how to load the 'viscosity' dataset and then describe it, grouped by the 'trial' variable. It shows summary statistics like mean, standard deviation, min, median, and max for 'batch' and 'viscosity' for each trial group. ```R data(viscosity) describe(viscosity, by = trial) ``` -------------------------------- ### Control qcc.options() settings Source: https://github.com/luca-scr/qcc/blob/master/NEWS.md In version 1.2, `qcc.options()` settings were updated: `run.length` defaults to 7 (previously 5), and `font.stats` and `cex.stats` control the font and character expansion for text at the bottom of control charts. ```R qcc.options(run.length = 7) qcc.options(font.stats = "bold") qcc.options(cex.stats = 1.2) ``` -------------------------------- ### Describe Circuit Data by Trial Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/circuit.html Provides descriptive statistics (mean, standard deviation, min, median, max) for the 'circuit' dataset, grouped by the 'trial' variable. This helps in comparing the characteristics of the samples based on whether they are from the initial or further inspection units. ```R describe(circuit, by = trial) #> ── trial = FALSE ─────────────────────────────────────────────────────────────── #> Obs Mean StdDev Min Median Max #> sample 20 36.5 5.916 27 36.5 46 #> x 20 18.3 4.714 9 18.5 28 #> size 20 100.0 0.000 100 100.0 100 #> #> ── trial = TRUE ──────────────────────────────────────────────────────────────── #> Obs Mean StdDev Min Median Max #> sample 26 13.50 7.649 1 13.5 26 #> x 26 19.85 7.165 5 19.0 39 #> size 26 100.00 0.000 100 100.0 100 ``` -------------------------------- ### Create and Plot Basic x-bar Chart Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html This snippet creates an x-bar control chart using the `qcc` function with phase I and phase II data. It then plots the chart, showing the control limits and data points. The `fill` argument controls whether the area between the control limits is filled. ```R (q1 <- qcc(diameter[1:25,], type = "xbar", newdata = diameter[26:40,])) ## __ Quality Control Chart _________________________ ## ## Chart type = xbar ## Data (phase I) = diameter[1:25, ] ## Number of groups = 25 ## Group sample size = 5 ## Center of group statistics = 74.00118 ## Standard deviation = 0.009785039 ## ## New data (phase II) = diameter[26:40, ] ## Number of groups = 15 ## Group sample size = 5 ## ## Control limits at nsigmas = 3 ## LCL UCL ## 73.98805 74.0143 plot(q1, fill = FALSE) plot(q1, chart.all = FALSE) plot(q1, add.stats = FALSE) ``` -------------------------------- ### Compute EWMA Smoothing - R Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/ewmaSmooth.html Computes the Exponential Weighted Moving Average (EWMA) for a series of data. The smoothed value z_t is calculated as lambda*y_t + (1-lambda)*z_{t-1}, where lambda controls the weight decay. The function takes vectors x and y, a smoothing parameter lambda, and an optional starting value. ```R ewmaSmooth(x, y, lambda = 0.2, start, ...) ``` ```R x = 1:50 y = rnorm(50, sin(x/5), 0.5) plot(x,y) lines(ewmaSmooth(x,y,lambda=0.1), col="red") ``` -------------------------------- ### Internal qcc Functions Usage - R Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/qcc-internal.html Demonstrates the usage of internal functions within the 'qcc' R package. These include utility functions for printing matrices and package startup messages. They are not designed for direct user invocation. ```R .printShortMatrix(x, head = 2, tail = 1, chead = 5, ctail = 1, ...) qcc.c4(n) qccStartupMessage() ``` -------------------------------- ### Prepare Data for x-bar Chart Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html This code prepares the 'pistonrings' dataset for creating an x-bar control chart. It uses the `qccGroups` function to group the diameter data, and `head` displays the first few rows of the processed data. ```R data(pistonrings) diameter <- qccGroups(data = pistonrings, diameter, sample) head(diameter) ## [,1] [,2] [,3] [,4] [,5] ## 1 74.030 74.002 74.019 73.992 74.008 ## 2 73.995 73.992 74.001 74.011 74.004 ## 3 73.988 74.024 74.021 74.005 74.002 ## 4 74.002 73.996 73.993 74.015 74.009 ## 5 73.992 74.007 74.015 73.989 74.014 ## 6 74.009 73.994 73.997 73.985 73.993 ``` -------------------------------- ### Example: OC Curve for xbar Chart with Piston Rings Data Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/oc.curves.html Demonstrates how to create an xbar control chart using the piston rings dataset and then generate its operating characteristic curve using ocCurves.xbar. The output shows the probability of Type II error for different shifts in the process mean. ```R data(pistonrings) diameter = qccGroups(diameter, sample, data = pistonrings) oc = ocCurves.xbar(qcc(diameter, type="xbar", nsigmas=3)) oc ``` -------------------------------- ### Create U Chart for PCManufactured Data in R Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Creates a U quality control chart using the `pcmanufact` dataset and the R qcc package. The code specifies the data, sample sizes, and chart type, then plots the resulting control chart. ```R data(pcmanufact) (q = with(pcmanufact, qcc(x, sizes = size, type = "u"))) plot(q) ``` -------------------------------- ### Generate Xbar Charts from T2 Chart Confidence Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/mqcc.html This example demonstrates how to derive individual Xbar charts for each variable from a multivariate T2 chart. It calculates the confidence level for the individual charts by taking the square root of the T2 chart's confidence level, ensuring consistency. The summary statistics for these individual charts are then displayed. ```R # Xbar-charts for single variables computed adjusting the # confidence level of the T^2 chart: q1 = with(RyanMultivar, qcc(X1, type = "xbar", confidence.level = q$confidence.level^(1/2))) summary(q1) q2 = with(RyanMultivar, qcc(X2, type = "xbar", confidence.level = q$confidence.level^(1/2))) summary(q2) ``` -------------------------------- ### Create p-chart with Different Dataset Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates a p-chart using the qcc function with the orangejuice2 dataset, comparing trial data with new data for phase II analysis. ```R data(orangejuice2) (q = with(orangejuice2, qcc(D[trial], sizes = size[trial], type = "p", newdata = D[!trial], newsizes = size[!trial]))) plot(q) ``` -------------------------------- ### Phase II Monitoring with New 'Out of Control' Data Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/mqcc.html This example demonstrates phase II monitoring with new data that is intentionally generated to be 'out of control' by shifting the mean. It uses `mvrnorm` with a modified mean (1.2 * q$center) and passes this data to `mqcc` with `newdata` and `pred.limits = TRUE`. The summary will reflect the out-of-control status. ```R # generate new "out of control" data Xnew = list(X1 = matrix(NA, 10, 4), X2 = matrix(NA, 10, 4)) for(i in 1:4) { x = mvrnorm(10, mu = 1.2*q$center, Sigma = q$cov) Xnew$X1[,i] = x[,1] Xnew$X2[,i] = x[,2] } qq = mqcc(RyanMultivar, type = "T2", newdata = Xnew, pred.limits = TRUE) summary(qq) ``` -------------------------------- ### Create X-bar Chart with Rules Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Creates an X-bar control chart with specified rules (1 to 4) and plots it for new data. This allows for the detection of special causes of variation beyond simple control limits. ```R q = qcc(diameter2[1:25,], type = "xbar", rules = 1:4) plot(qcc(diameter2[1:25,], type = "xbar", newdata = diameter2[26:40,], rules = 1:4)) ``` -------------------------------- ### Create Pareto Chart Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates a Pareto chart to visualize defect frequencies and their cumulative percentages. It requires a named vector of defect counts. The output is a Pareto chart object that can be plotted. ```R defect <- c(80, 27, 66, 94, 33) names(defect) <- c("price code", "schedule date", "supplier code", "contact num.", "part num.") (pc = paretoChart(defect, ylab = "Error frequency")) plot(pc) ``` -------------------------------- ### Process Capability Analysis (qcc) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/index.html Performs process capability analysis to assess if a process meets specifications. Supports various statistical measures. ```R processCapability() print(__) plot(__) ``` -------------------------------- ### Create p-chart with New Data Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Creates a p-chart using the qcc function, specifying trial data, group sizes, and new data for phase II analysis. Out-of-control points from the trial data are excluded. ```R inc <- setdiff(which(orangejuice$trial), c(15,23)) (q = with(orangejuice, qcc(D[inc], sizes = size[inc], type = "p", newdata = D[!trial], newsizes = size[!trial]))) plot(q) ``` -------------------------------- ### Print Process Capability Results Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/processCapability.html Prints the results of a process capability analysis, typically including capability indices and their confidence limits. It formats the output for readability. ```R print(x, digits = getOption("digits"), ...) ``` -------------------------------- ### Create p-chart with QCC Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates a p-chart (proportion nonconforming) using the qcc function with the orangejuice dataset. It calculates control limits based on the trial data. ```R data(orangejuice) (q = with(orangejuice, qcc(D[trial], sizes = size[trial], type = "p"))) plot(q) ``` -------------------------------- ### Add head.start argument to cusum function Source: https://github.com/luca-scr/qcc/blob/master/docs/news/index.html The `cusum` function in qcc version 2.7 includes a new `head.start` argument, allowing for more control over the cumulative sum calculation. ```R cusum(..., head.start = TRUE) ``` -------------------------------- ### Create R Chart with QCC Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates an R chart (range chart) using the qcc function from the QCC package. It utilizes preprocessed data and plots the chart for the first 25 groups. ```R plot(qcc(diameter2[1:25,], type = "R")) ``` -------------------------------- ### Creating EWMA Charts with QCC Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Illustrates the creation of Exponentially Weighted Moving Average (EWMA) charts using the QCC package in R. This includes setting the smoothing parameter (lambda) and the number of standard deviations for control limits, and applying it to both phase I and phase II data. ```R data(pistonrings) diameter <- qccGroups(data = pistonrings, diameter, sample) (q = ewma(diameter[1:25,], lambda = 0.2, nsigmas = 3)) plot(q) ``` ```R (q = ewma(diameter[1:25,], lambda = 0.2, nsigmas = 2.7, newdata = diameter[26:40,])) plot(q) plot(q, xtime = seq(Sys.Date() - nrow(diameter)+1, Sys.Date(), by = 1), add.stats = FALSE) + scale_x_date(date_breaks = "4 days", date_labels = "%d-%b") ``` -------------------------------- ### Generate X-bar, R, and S charts for mixture Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html This code simulates data from a mixture of two processes with different means and generates X-bar, R, and S control charts. It defines the means of the two processes (mu1, mu2), standard deviation, and the probability 'p' of belonging to the first process. The data 'x' is generated based on these parameters and plotted. ```R mu1 <- 90 mu2 <- 110 sigma_W <- 10 epsilon <- rnorm(500) p <- rbinom(50, 1, 0.5) mu <- mu1*p + mu2*(1-p) x <- rep(mu, rep(10, length(mu))) + sigma_W*epsilon x <- matrix(x, ncol = 10, byrow = TRUE) plot(qcc(x, type = "xbar", rules = 1:4)) ``` ```R plot(qcc(x, type = "R", rules = 1:4)) ``` ```R plot(qcc(x, type = "S", rules = 1:4)) ``` -------------------------------- ### Create and Plot u-chart from pcmanufact Dataset (R) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/qcc.html This code shows how to create and plot a u-chart from the 'pcmanufact' dataset using the 'qcc' function in R. It specifies 'type="u"' for a u-chart and displays the resulting control chart and its summary. ```R q1 = with(pcmanufact, qcc(x, sizes=size, type="u")) q1 plot(q1) ``` -------------------------------- ### Create C Chart with R qcc Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates a C quality control chart using the qcc function from the R qcc package. This involves specifying the data, sample sizes, and chart type. The output includes chart statistics and a plot. ```R data(circuit) (q = with(circuit, qcc(x[trial], sizes = size[trial], type = "c"))) plot(q) ``` -------------------------------- ### Create Cusum Chart Object (R) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/cusum.html The `cusum` function creates an object of class 'cusum.qcc' for statistical quality control. It requires observed data, sample sizes, process center, and standard deviation. Optional arguments control decision intervals, shifts, and initial values. ```R cusum(data, sizes, center, std.dev, decision.interval = 5, se.shift = 1, head.start = 0, newdata, newsizes, ...) ``` -------------------------------- ### Boxplot of Defect Rate by Trial Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/circuit.html Generates a boxplot to visualize the distribution of the defect rate (x/size) for the 'circuit' dataset, separated by the 'trial' indicator. This plot helps in identifying differences in defect rates between the two trial groups. ```R boxplot(x/size ~ trial, data = circuit) ``` -------------------------------- ### Create np-chart with QCC Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates an np-chart (number nonconforming) using the qcc function with the orangejuice dataset. It calculates control limits based on the trial data. ```R (q = with(orangejuice, qcc(D[trial], sizes = size[trial], type = "np"))) plot(q) ``` -------------------------------- ### Define a new control chart: standardized p chart Source: https://github.com/luca-scr/qcc/blob/master/NEWS.md Version 2.4 includes a demo showcasing how to extend the qcc package by defining a new control chart, specifically the standardized p chart. ```R demo("standardized_p_chart", package="qcc") ``` -------------------------------- ### Describe Boiler Data Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/boiler.html Provides a summary description of the 'boiler' dataset, including mean, standard deviation, minimum, median, and maximum values for each temperature reading (t1-t8). ```R describe(boiler) #> Obs Mean StdDev Min Median Max #> t1 25 525.0 7.348 507 527 536 #> t2 25 513.6 2.200 509 514 518 #> t3 25 538.9 4.795 527 540 546 #> t4 25 521.7 4.723 512 523 530 #> t5 25 503.8 3.379 497 504 509 #> t6 25 512.4 2.123 508 512 517 #> t7 25 478.7 3.410 471 480 483 #> t8 25 477.2 1.964 472 477 481 ``` -------------------------------- ### Create X-bar Chart (One-at-a-Time Data) Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html This code snippet demonstrates how to create an X-bar control chart for one-at-a-time data using the qcc function from the qcc package in R. It calculates the control limits based on the provided data. ```R data(viscosity) (q = with(viscosity, qcc(viscosity[trial], type = "xbar.one"))) plot(q) ``` -------------------------------- ### Load and Inspect RyanMultivar Data (R) Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/RyanMultivar.html This snippet demonstrates how to load the RyanMultivar dataset into R and inspect its structure. It shows the data is a list containing two numeric matrices, X1 and X2, representing the multivariate data. ```R data(RyanMultivar) str(RyanMultivar) #> List of 2 #> $ X1: num [1:20, 1:4] 72 56 55 44 97 83 47 88 57 26 ... #> $ X2: num [1:20, 1:4] 23 14 13 9 36 30 12 31 14 7 ... ``` -------------------------------- ### Create Xbar Chart for X2 Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates an Xbar control chart for the 'X2' variable from the RyanMultivar dataset. Similar to the X1 chart, the confidence level is adjusted based on the 'q' object's confidence level. ```R with(RyanMultivar, qcc(X2, type = "xbar", confidence.level = q$confidence.level^(1/2))) ``` -------------------------------- ### Load Orange Juice Data | R Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/orangejuice2.html Loads the orangejuice dataset into the R environment. This is a prerequisite for further analysis or visualization. ```R data(orangejuice) ``` -------------------------------- ### Direct calling of cusum() and ewma() Source: https://github.com/luca-scr/qcc/blob/master/NEWS.md In qcc version 2.0, `cusum()` and `ewma()` functions were rewritten to be called directly with data and arguments, eliminating the need to create a `qcc` object beforehand. ```R cusum(data, ...) ewma(data, ...) ``` -------------------------------- ### Create x-bar Chart with Western Electric Rules Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html This snippet demonstrates creating an x-bar control chart that incorporates the Western Electric rules (rules 1 through 4) for detecting out-of-control points. The chart is then plotted, with and without filling the area between control limits. ```R q1 <- qcc(diameter[1:25,], type = "xbar", newdata = diameter[26:40,], rules = 1:4) plot(q1) plot(q1, fill = FALSE) ``` -------------------------------- ### Create X-bar Chart with QCC Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Generates an X-bar control chart using the qcc function from the QCC package. It preprocesses data by removing outliers and plotting the chart for the first 25 groups. ```R out <- c(9, 10, 30, 35, 45, 64, 65, 74, 75, 85, 99, 100) diameter2 <- qccGroups(data = pistonrings[-out,], diameter, sample) plot(qcc(diameter2[1:25,], type = "xbar")) ``` -------------------------------- ### Analyze Process Variation with X-bar Chart Source: https://github.com/luca-scr/qcc/blob/master/docs/articles/qcc.html Simulates data representing simple random variation and plots an X-bar control chart to monitor the process mean. It uses a specified mean (mu) and standard deviation (sigma_W) for data generation and applies control rules. ```R mu <- 100 sigma_W <- 10 epsilon <- rnorm(500) x <- matrix(mu + sigma_W*epsilon, ncol = 10, byrow = TRUE) plot(qcc(x, type = "xbar", rules = 1:4)) ``` -------------------------------- ### Plot Process Capability Chart Source: https://github.com/luca-scr/qcc/blob/master/docs/reference/processCapability.html Generates a process capability chart using the `processCapability` function. This function requires the data, specification limits, and optionally a target value. It visualizes the process's ability to meet specifications. ```R plot(processCapability(q, spec.limits=c(73.95,74.05), target=74.02)) ``` ```R plot(processCapability(q, spec.limits=c(73.99,74.01))) ``` ```R plot(processCapability(q, spec.limits = c(73.99, 74.1))) ```