0

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

duckmayr
  • 16,303
  • 3
  • 35
  • 53
  • 1
    Please provide minimal and reproducible example(s) along with the desired output. Use `dput()` for data and specify all non-base packages with `library()` calls. – Edward Jun 28 '20 at 14:06

1 Answers1

0

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

Paul van Oppen
  • 1,443
  • 1
  • 9
  • 18
  • Hi Paul, a question please, I need insert axes from 1990 to 2019, to appear in time step 5 year (1990,1995,2000.....), I tried used this syntax, but the vector size it is different of computeded in ewma. There is a way to achive it? – Guilherme Lopes de Campos Jul 08 '20 at 11:51
  • You can infer the number of x-axis ticks from the data in `q2`: `nrow(q2$data)` returns 25 in my example. So your `label` vector requires 25 elements. – Paul van Oppen Jul 09 '20 at 06:26