title: How to extract or calcualte special cause variations shown in a qcc chart (xmr, spc)
body: <p>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.</p>
  
  <p>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'.</p>
  
  <p>Q1 . What is wrong with my for loop that is meant to detect 'seven points continually increasing'. 
  Error message:</p>
  
  <pre><code>Error in incremnt : object 'incremnt' not found
  </code></pre>
  
  <p>Q2. how can I get the gcc chart to show the date on the x-axis</p>
  
  <p>Useful links that I used for this project:</p>
  
  <p><a href="https://improvement.nhs.uk/documents/2171/statistical-process-control.pdf" rel="nofollow noreferrer">https://improvement.nhs.uk/documents/2171/statistical-process-control.pdf</a>
  <a href="https://www.r-bloggers.com/xmr-chart-step-by-step-guide-by-hand-and-with-r/" rel="nofollow noreferrer">https://www.r-bloggers.com/xmr-chart-step-by-step-guide-by-hand-and-with-r/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38661660/spc-control-charts-by-group-in-r">SPC - Control Charts by Group in R</a></p>
  
  <pre><code>....R
  install.packages("qcc")
  install.packages("ggQC")
  library(qcc)
  library(ggQC)
  
  
  exampl_data &lt;- 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 &lt;- qcc(exampl_data$Length, type = "xbar.one", plot = FALSE)
  # add warning limits at 2 and 3 std. deviations
  (warn.limits  &lt;- limits.xbar(qcc_chart$center, qcc_chart$std.dev, qcc_chart$sizes, 1))
  (warn.limits2 &lt;- 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 &lt;- 0
    while (exampl_data$Length[i + increment] &lt;= exampl_data$Length[(i + increment) +
                                                                   1] &amp; increment &lt; 8)
    {
      if (incremnt == 7)
      {
        print(exampl_data$Length[i + increment])
        break()
      }
      increment &lt;- increment + 1
    }
  }
  
  
  ....
  </code></pre>