library(qcc)
# Sample viscosity measurements from production batches
viscosity <- c(
4520, 4535, 4510, 4525, 4540,
4515, 4530, 4505, 4545, 4520,
4525, 4510, 4535, 4515, 4530
)
# Arrange 3 subgroups with 5 measurements each
viscosity_matrix <- matrix(viscosity, ncol = 5, byrow = TRUE)
# Create X-bar chart
qcc(viscosity_matrix, type = "xbar")Statistical Process Control for Cosmetic Manufacturing
Introduction
Statistical Process Control (SPC) is one of the most practical tools for separating normal process variation from signals that actually require action. In cosmetics manufacturing, that matters because not every drift in viscosity, pH, or fill weight means the process is broken, but missing a real shift can become expensive very quickly.
This post walks through a simple R workflow for subgrouped control charts, with a cosmetics-flavoured example based on viscosity measurements.
The Basics of SPC
SPC uses control charts to monitor process behaviour over time. Key concepts:
- Center Line (CL) — The process average
- Upper Control Limit (UCL) — CL + 3σ
- Lower Control Limit (LCL) — CL - 3σ
The important distinction is between:
- common-cause variation — the ordinary fluctuation of a stable process
- special-cause variation — a signal that something has changed and should be investigated
The purpose of a control chart is not to punish noise. It is to detect the second category without overreacting to the first.
Implementing Control Charts in R
Suppose you sample five jars from each production subgroup and record viscosity.
X-bar Chart Example
For subgrouped data, a matrix is clearer than a long vector because each row represents one subgroup.
R Chart for Variability
# R chart for within-subgroup variability
qcc(viscosity_matrix, type = "R")The X-bar chart tells you whether the subgroup means are shifting. The R chart tells you whether within-subgroup variability is changing. You generally want to review them together.
Detecting Out-of-Control Conditions
Common patterns to watch for:
- Points beyond control limits — Immediate investigation needed
- Run of 7+ points — Process shift detected
- Trends — Gradual drift in process
- Hugging the center line — Possible measurement issues
In a cosmetics setting, these signals often map to practical questions:
- Was there a raw material change?
- Did the mixing time drift?
- Was the line cleaned or recalibrated?
- Did one operator, vessel, or shift behave differently?
Automating daily monitoring
Once the chart logic is stable, the next step is usually not a bigger chart. It is a repeatable monitoring workflow.
A simple automation path looks like this:
- Pull the latest process measurements from the laboratory or manufacturing system.
- Rebuild subgrouped data by batch, time window, or line.
- Regenerate X-bar and R charts on a schedule.
- Flag special-cause rules for review.
- Store the charts and investigation notes together.
If you do want a dashboard, a small Shiny app can work well, but the app should sit on top of a validated charting workflow rather than replace it.
Conclusion
SPC is powerful precisely because it turns vague process anxiety into explicit signals. With R, it is straightforward to build charts that are reproducible, reviewable, and easy to automate. The main challenge is not the code. It is choosing sensible subgrouping, knowing what constitutes a meaningful signal, and making sure the investigation path is as clear as the chart itself.
Further Reading
- Montgomery, D.C. “Introduction to Statistical Quality Control”
- ISO 22716: Cosmetics Good Manufacturing Practices