rplotaxesqcc

Modify axes in control chart RStudio


I would like to ask a help in modify axes in control chart in RStudio, by qcc package.

Generated a controlchart type EWMA, in the axes x, appear group, sequencially (that represents each observations), but I need insert an information about year (divide group into sequence of year). I tried using the command (axes), but doesn't work.

Which command or function it is possible to modify to achieve this?

Thank you very for help!

Need change the group sequence in axes x to appear year of observation

Yours faithfully

Guilherme


Solution

  • The ewma function inqcc accepts a labels parameter: a character vector of labels for each group. You could, for instance, do something like:

    library(qcc)
    
    data(pistonrings)
    attach(pistonrings)
    diameter <- qcc.groups(diameter, sample)
    
    label_x <- as.character(seq.Date(from = as.Date("2020/01/01"), length.out = 25, by = "day"))
    
    q2 <-
       ewma(
        diameter[1:25, ],
        center = 0,
        lambda = 0.4,
        std.dev = 0.57,
        nsigmas = 3,
        add.stats = FALSE,
        labels = label_x
      ) 
    

    And end up with a properly labelled x-axis in your EWMA plot: enter image description here