r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 755 forks source link

Wrong percentage values in processCapability() #2490

Closed Vst13 closed 1 year ago

Vst13 commented 1 year ago

Hi, me and my friend found out that processCapability() function may display wrong percentage values of Exp<LSL, Exp>USL, Obs<LSL, Obs>USL. I downloaded devtools yesterday so I think I have the latest version. The problem is that proportions are not converted into percentages when displayed in console or in chart. For example when fraction of observations greater than USL is equal to 0.04, it is not displayed as 4% of all observations but as 0.04%. My friend used process.capability() function and she got correct results so it may be just a little problem with not multiplying the 'obs' and 'exp' values by 100 before displaying them with '%' symbol.

library(qcc)
library(SixSigma)

data(pistonrings)
pistonrings
q <- pistonrings |> qccGroups(diameter, sample) |> qcc(type="xbar")
lsl <- 73.975
usl <- 74.025

pc <- processCapability(object=q, spec.limits=c(lsl,usl))
plot(pc) #Obs>USL displayed as 0.04%

pc

#fraction of observations greater than USL
pc$obs[2]
#or
library(dplyr)
n <- pistonrings |> filter(diameter>usl) |> nrow()
all <- pistonrings |> nrow()
n/all 
#fraction of Obs>USL equals 0.04 so it's 4% of all observations, not 0.04%
jennybc commented 1 year ago

This doesn't seem related to the devtools package. I suspect you need to find the right place for discussing issues about the qcc and/or SixSigma packages.