Some Six Sigma Quality Control Charts in R

There is a CRAN package available in R, authored and maintained by Luca Scrucca , that has many nice functions within that are very much geared for Six Sigma work. I just used it to very easily to produce an XmR (X-bar and moving range) plot for some data we have been working with. Here is an example of output:

Approver Process XmR

This is clearly showing the upper and lower control limits, those observations which are out of control within 3 sigma and outwith. Here is the code that I used to generate the plot, working from an existing data frame that I already had.

    # Using qcc to get a simple XmR
    library(qcc)
 
    # Get the vector of observations in which are interested
    my.xmr.raw <- approverDF$Duration.AT
 
    # Create the individuals chart and qcc object
    my.xmr.x <- qcc(my.xmr.raw, type = "xbar.one", plot = T)
 
    # Create a moving range chart as a qcc object. This takes a 2-col matrix that is used
    # to calculate the moving range.
    my.xmr.raw.r  <- matrix(cbind(my.xmr.raw[1:length(my.xmr.raw)-1],
                              my.xmr.raw[2:length(my.xmr.raw)]),
                             ncol = 2)
 
    # Make the XmR plot
    my.xmr.mr <- qcc(my.xmr.raw.r, type="R", plot = T,
                     add.stats = T,
                     title = "Approval Process X-bar nand Moving Range Chart",
                     xlab = "Approval Tasks",
                     ylab = "Duration (days)",
                     axes.las = 0)

Created by Pretty R at inside-R.org

Which is simple enough. The package has goodies for Shewhart quality control charts for continuous, attribute and count data. Cusum and EWMA charts. Operating characteristic curves. Process capability analysis. Pareto chart and cause-and-effect chart. Multivariate control charts.

The only issues that I can see are that it isn’t leveraging any goodness from ggplot2, which is my defacto plotting library in R. Furthermore, it appears that there is some dated approaches involved with QCC, as evidenced by the multiple references to attach found in the documentation. I will dig through it a bit to see how much of it is stylistic and how much is actual, fossilized dependency. Thanks for the work, Luca.

And, nicely placed is also a way to run your fishbones programatically. So, here is an output:

http://66.147.244.76/~shawnmeh/blog/wp-content/uploads/2015/08/Fishbone.png

and the simple code to produce it:

    # Using qcc to get a simple XmR
    library(qcc)
 
    cause.and.effect(cause=list(Measurements=c("Micrometers", "Microscopes", "Inspectors"),
                            Materials=c("Alloys", "Lubricants", "Suppliers"),
                            Personnel=c("Shifts", "Supervisors", "Training", "Operators"),
                            Environment=c("Condensation", "Moisture"),
                            Methods=c("Brake", "Engager", "Angle"),
                            Machines=c("Speed", "Lathes", "Bits", "Sockets")),
                effect="Surface Flaws")

Created by Pretty R at inside-R.org

That’s a nice touch and nice bonus. I will be using the package for this gem as well.

twitter
twitter

Leave a Reply

Your email address will not be published. Required fields are marked *