1

I have come across quality control charts, my question is how does the qcc package handle missing values i.e.

library(qcc)
diameters <- as.data.frame(replicate(2, rnorm(10,mean=1.31,sd=0.05)))
diameters
diameters[1,1]<-NA
q <- qcc(diameters, type="R", nsigmas=3)
q <- qcc(diameters, type="xbar.one", nsigmas=3)

When plotting the R chart it makes sense to me to get an error, but why when using a xbar.one chart? Is there a way to handle NA, like not showing this points at all instead of giving an error?

  • 1
    The documentation for the package is vague with respect on handling NA. I would guess here creators would assume if the value is NA, then it is an invalid measurement and should be excluded from the chart. I would suggest filtering your data with "complete.cases()" before the function calls. – Dave2e May 25 '16 at 17:26
  • Thanks for your answer Dave. That is by now the only workaround I have found so far but not optimal, since showing an NA on the chart would not directly mean "invalid" measurement but i.e. "the value could not be measured" or something similar – poleteiep34 May 31 '16 at 10:56

1 Answers1

0

How it handles missing values depends on the chart you're plotting. I've found the best way to deal with missing values is to eliminate them using na.rm = TRUE.

Alternatively you can omit na:

df <- na.omit(df)

or, especially when creating control charts that require groups that exist in another column in your dataframe, use the complete cases method as suggested by @Dave2E:

df <- df[complete.cases(df), ]
L Tyrone
  • 1,268
  • 3
  • 15
  • 24