I created a qcc chart in R and would like to hold the special cause variations from the qcc chart in variables for use else where.
I have tried to extract the special causes for chart 'Number beyond limits' and 'Number violating runs' with no luck. So I am trying to recalculate the special causes staring with 'seven points continually increasing'.
Q1 . What is wrong with my for loop that is meant to detect 'seven points continually increasing'. Error message:
Error in incremnt : object 'incremnt' not found
Q2. how can I get the gcc chart to show the date on the x-axis
Useful links that I used for this project:
https://improvement.nhs.uk/documents/2171/statistical-process-control.pdf https://www.r-bloggers.com/xmr-chart-step-by-step-guide-by-hand-and-with-r/
SPC - Control Charts by Group in R
....R
install.packages("qcc")
install.packages("ggQC")
library(qcc)
library(ggQC)
exampl_data <- data.frame(
# ScrewID = as.factor(1:20),
ScrewID = seq(as.Date("2000/1/1"), by = "month", length.out = 20),
Length = c(
2.92, 3.16, 2.88, 2.90, 2.92,
2.94, 2.96, 2.98, 3.02, 2.67,
3.09, 3.07, 3.04, 3.06, 3.05,
3.03, 3.07, 2.91, 3.07, 3.30
)
)
qcc_chart <- qcc(exampl_data$Length, type = "xbar.one", plot = FALSE)
# add warning limits at 2 and 3 std. deviations
(warn.limits <- limits.xbar(qcc_chart$center, qcc_chart$std.dev, qcc_chart$sizes, 1))
(warn.limits2 <- limits.xbar(qcc_chart$center, qcc_chart$std.dev, qcc_chart$sizes, 2)
)
plot(qcc_chart, restore.par = TRUE)
abline(h = warn.limits, lty = 3, col = "gray")
abline(h = warn.limits2, lty = 3, col = "gray")
# Not working: My attempt at loop to identify 7 row of incresing values
for (i in 1:length(exampl_data$Length))
{
increment <- 0
while (exampl_data$Length[i + increment] <= exampl_data$Length[(i + increment) +
1] & increment < 8)
{
if (incremnt == 7)
{
print(exampl_data$Length[i + increment])
break()
}
increment <- increment + 1
}
}
....