Giter Club home page Giter Club logo

ggqc's Introduction

Description

Plot single and multi-facet quality control charts within the ggplot framework using stat_QC and stat_mR. Calculate quality control limits using QC_Lines.

Methods supported:

  • Individuals Charts : mR, XmR
  • Attribute Charts : c, np, p, u
  • Studentized Charts: xBar.rBar, xBar.rMedian, xBar.sBar, xMedian.rBar, xMedian.rMedian
  • Dispersion Charts: rBar, rMedian, sBar

Example

library(ggplot2)
library(ggQC)


set.seed(5555)
Golden_Egg_df <- data.frame(month=1:12,
                 egg_diameter = rnorm(n = 12, mean = 1.5, sd = 0.2)
                 )

XmR_Plot <- ggplot(Golden_Egg_df, aes(x = month, y = egg_diameter)) +
               geom_point() + geom_line() + 
               stat_QC(method = "XmR")

XmR_Plot

Installation

  • cran: install.package("ggQC")
  • github: devtools::install_github("kenithgrey/ggQC")

Overview

  • QC_Lines(): Output quality control chart data in table format
  • QC_Violations(): Check for QC Violations
  • stat_QC(): ggplot stat to generate control charts supported methods
  • stat_mR(): ggplot stat to generate mR chart.
  • stat_QC_labels(): ggplot stat to write text labels on control chart center line and limits.
  • stat_qc_violations(): ggplot stat to examine QC Violations.
  • 30 plus functions to calculate specific control chart constants. (recommend using QC_Lines())

More Examples

For more Information and Examples using ggQC, visit (rcontrolcharts.com)

ggqc's People

Contributors

kenithgrey avatar mwalzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ggqc's Issues

Regarding Levey-Jennings-Chart?

Hi!
Thank you for your great efforts here!

I was wondering whether there is a function contained in this package to perform Levey-Jennings-Chart?

Best,
Payam

replacement has 10 rows, data has 20

Hi,

I recently updated some data that I have been running through the QC_Violations function. For some reason a particular set of values seems to trigger the following error message:

> Error in `$<-.data.frame`(`*tmp*`, "Violation_Same_Side", value = c(TRUE,  : 
>   replacement has 10 rows, data has 20

I've been unable to ascertain exactly what is causing the error, but am able to consistently reproduce it.

# Values which originally triggered the error msg
x1 <- c(
         0.728358208955224, 0.69198606271777, 0.696148359486448, 0.725755166931638, 
         0.729329173166927, 0.718320610687023, 0.70610119047619, 0.724165341812401, 
         0.742485783915516, 0.730029585798817, 0.798306389530408, 0.818871103622578, 
         0.769933554817276, 0.777939042089985, 0.814540059347181, 0.835034013605442, 
         0.789566755083996, 0.802180685358255, 0.802058590657165, 0.812206572769953
         )

QC_Violations(data=x1, method = "XmR")


# Changing the last value to 0.999 stops the error from flagging
x2 <- c(
  0.728358208955224, 0.69198606271777, 0.696148359486448, 0.725755166931638, 
  0.729329173166927, 0.718320610687023, 0.70610119047619, 0.724165341812401, 
  0.742485783915516, 0.730029585798817, 0.798306389530408, 0.818871103622578, 
  0.769933554817276, 0.777939042089985, 0.814540059347181, 0.835034013605442, 
  0.789566755083996, 0.802180685358255, 0.802058590657165, 0.999
)

QC_Violations(data=x2, method = "XmR")


# random values seem to work
QC_Violations(data=rnorm(20), method = "XmR")

# sequential values don't
QC_Violations(data=as.numeric(1:20), method = "XmR")

# sometimes adding random values to sequential values works, sometimes it doesn't
QC_Violations(data=as.numeric(1:20) + rnorm(20), method = "XmR")

There is some discussion of this error message here, however I haven't been able to figure out how that applies to this scenario.

I'm running ggQC version 0.0.3 on R 4.3.2, using RStudio 2023.06.0 Build 421. on a Windows 10 machine.

Multiple lines

When using ggQC I get multiple upper and lower control lines,
Bildschirmfoto 2023-11-26 um 19 52 26

Here is the code, which I use

# Socket Thickness Data
file.path = '~/Documents/R-Programs/WheelerDonald/'
file.name = 'data_Wheeler_SocketThickness.csv'
DF = read.table(paste0(file.path, file.name), sep=",", header = TRUE)

##
# Combine time and cycles and generate a new column:
DF$subGrp = paste0(DF$time, DF$cycles)
ggplot(DF, aes(x=subGrp, y=y, color=color)) + stat_QC(method="xBar.rBar")

I also tried to convert "subGrp" into a factor, but the result is the same. I append the dataset.

data_Wheeler_SocketThickness.csv

The Cpk value seems not correct for the one-sided specification when using the function of CapabilityAnaylsis

For example, when setting LSL=NULL as below, the calculated Cpk is 7.39. However, the correct Cpk should be 2.46. Could the author help to review the code?

CapabilityAnaylsis <-
ggplot(Process_Data, aes(x = Value)) + #init ggplot
geom_histogram(binwidth = .75, color="purple") + #make the histogram
stat_QC_Capability(
LSL=NULL, USL=37, #Specify LSL and USL
show.cap.summary = c("Cp", "Cpk", "Pp, "Ppk"), #selected summary
digits = 2, #report two digits
method="XmR") + #Use the XmR method
scale_x_continuous(expand = expand_scale(mult = c(0.15,.65))) #pad the X-axis
CapabilityAnaylsis

Unequal subgroup sizes

It seems XBar functions and graphs ignore subgroup sizes (unweighted mean, std dev etc are used - e.g. in XCentral_LimitFUN in the source). It would be great if this could be incorporated.

Pareto chart order or fct_reorder

Hi, Sr. thank you for this package.

Apparently, the code is running, but I'm having some problems with the order of the frequency in the chart.

e.g( holes has the highest value but it's the scratch that appears first on the chart)

library(tidyverse)
library(ggQC)

df <- tibble(type_nc = c("scratch","spots","folds","holes","rips"),
                       qty = c(201,78,47,31,15),
                       cost = c(4287,2423,1119,8947,1864))
df

df %>% 
  ggplot(aes(x = type_nc,
             y= cost)) + 
  stat_pareto(point.color = "navy",
              point.size = 2,
              line.color = "navy",
              bars.fill = c("blue","lightblue"))

Thank you

secondary axis

How can add a grid only for the secondary axis (cummulative %)?

The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0

Warning:
The fun.y argument of stat_summary() is deprecated as of ggplot2 3.3.0.
ℹ Please use the fun argument instead.
ℹ The deprecated feature was likely used in the ggQC package.
Please report the issue to the authors.

Backtrace:

  1. └─ggQC::stat_QC(method = "xBar.rBar", auto.label = T, label.digits = 2)
  2. └─ggplot2::stat_summary(...)
  3. └─ggplot2:::deprecate_warn0("3.3.0", "stat_summary(fun.y)", "stat_summary(fun)")
    

stat_pareto mislabels the x axis unless x data are alphabetized

While the bars show up in the correct order (largest to smallest), their labels are incorrect any time x is not in alphabetical order. Could this be fixed?

# first set alphabetized, second not, but with same value order
sorted     <- data.frame(label = c("A",   "B",   "C",     "D"),    value = c(20, 15, 10, 5))    
not_sorted <- data.frame(label = c("One", "Two", "Three", "Four"), value = c(20, 15, 10, 5))    

# this one labels bars correctly
ggplot(sorted, aes(x = label, y = value)) +

    ggQC::stat_pareto(point.color = "red",
                point.size = 2,
                line.color = "black",
                bars.fill = c("coral", "yellow"))
    
# this one does not label bars correctly
ggplot(not_sorted, aes(x = label, y = value)) +

    ggQC::stat_pareto(point.color = "red",
                point.size = 2,
                line.color = "black",
                bars.fill = c("coral", "yellow"))

Residual Points Persist in X-bar Chart

The image below shows black points inside green points on an X-bar chart built by following the example in this vignette (plot title removed). The green larger points were set by my code (below). However the default black points persist. I have changed the order of layers setting individual measurement points first (faded gray) followed by average measurements green points with zero transparency and the faded points seem to have been masked by the green points.
The black points together with the lines however, are not masked by the green points.

ggQC package version: 0.0.31

Thank you!

Xbar_plot

Xbar = lapply(unique(VectorData), function(i) {
       ggplot(dtt[Item %in% i], aes(x = Sample, y = .data[['Area/\u03BCL']], group = 1L)) +
       theme_bw() + geom_point(alpha = 0.2, size = 2) +
       stat_summary(fun = 'mean', geom = 'point', size = 4, color = '#17b903') + 
       stat_summary(fun = 'mean', geom = 'line') + 
       theme(axis.text.x = element_text(size = 6, angle = 90, vjust = 0.5, hjust=1)) +
       ggtitle(sprintf('%s  | Item : %s', equip, i)) + 
       scale_x_discrete(expand = expansion(add = c(1L, 2L))) +
       stat_QC() + stat_QC_labels(text.size = 2)
    })

Message "fun.y deprecated" Still Appears When Using "fun" Argument Instead of "fun.y"

Using stat_summary() with argument fun does not prevent the

Warning message:
The fun.y argument of stat_summary() is deprecated as of ggplot2 3.3.0.
ℹ Please use the fun argument instead.
ℹ The deprecated feature was likely used in the ggQC package.
Please report the issue to the authors.
This warning is displayed once every 8 hours.
Call lifecycle::last_lifecycle_warnings() to see where this warning was generated:


Backtrace:

  1. base::lapply(...)
  2. global FUN(X[[i]], ...)
  3. ggQC::stat_QC()
  4. ggplot2::stat_summary(...)
  5. ggplot2:::deprecate_warn0("3.3.0", "stat_summary(fun.y)", "stat_summary(fun)")

I am rising this issue for the reason that package `ggQC` is mentioned in the warning. 

`ggQC` package version: 0.0.31

Thank you!

P Charts do not carry limits through

When trying to plot new data on the set control limit lines, if you use anything but the XmR option, the control limits only show for the "Setup"/"pre_change"

#Data Generation
dat_i <- data.frame(mnth = 1:24,
r_cnt = rbinom(24,100,prob = p_red),
DataType = "pre_change"
)
dat_i$r_p = dat_i$r_cnt/100

dat_n <-
data.frame(mnth = 25:36,
r_cnt = rbinom(24,100,prob = .15),
DataType = "post_change"
)
dat_n$r_p = dat_n$r_cnt/100
dat_all <- rbind(dat_i,dat_n)

#Plotting the Data
P_Plot <-
ggplot(dat_all, aes(x = mnth, y = r_p, n = 100)) +
geom_point() + geom_line() +
stat_QC(data = dat_all[dat_all$DataType=="pre_change",],
method = "p",
auto.label = T,
label.digits = 2,
show.1n2.sigma = T
) +
scale_x_continuous(expand = expansion(mult = .15))

P_Plot

violation_point.color

Hello,
Thank you in advance for your help! I am utilizing your package and I am having an issue with the point color for qc violations. I was hoping you would have an idea of what I am doing wrong.

m_base_count <- ggplot(diehard, aes(x = Date Opened, y = n)) + stat_qc_violations(method = "XmR", violation_point.color = "Red") + ggtitle("All Violations") m_base_count

screenshot_2018-12-13 qa dashboard

Please let me know if the picture does not work. I am very to Github.

"lineWidth" Argument in stat_summary() Not Recognized

The code for this Issue is posted in Issue #51:

Using argument size in stat_summary(geom = 'line', size = 1) throws the following warning:

<warning/lifecycle_warning_deprecated>
Warning:
Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
---
Backtrace:
 1. ggplot2::stat_summary(...)
 2. ggplot2::layer(...)
 3. ggplot2:::deprecate_soft0(...)

However, changing the argument to stat_summary(geom = 'line', lineWidth = 1) throws the following

Warning message:

In stat_summary(fun = "mean", geom = "line", lineWidth = 0.5, color = "gray90") :
  Ignoring unknown parameters: `lineWidth`

ggQC package version: 0.0.31

Thank you!

stat_QC issue warning `fun.y` deprecated

When running the following code, I got warning message "fun.y is deprecated"
After dumping the function code, I think is cause by stat_QC.
How can I fix this?

process1 <- data.frame(x=vdata,subgroup=rep(1:25,each=5)) basechart <- ggplot(process1,aes(x=subgroup,y=x) ) xbar1 <- basechart + stat_QC(method = "xBar.rBar", auto.label = T, label.digits = 2)

Warning messages:
1: fun.y is deprecated. Use fun instead.
2: fun.y is deprecated. Use fun instead.

Thank you for your great work.

Unequal Values QC_Lines vs Stat_QC

Hello,

I was attempting to extract my control limits and utilize those limits in additional plots in a sustainable manner so I wanted to extract a table format of the QC constants. However, upon doing so I found that the LCL and UCL calculated by the graph(Stat_QC) were different than the limits calculated by QC_Lines(). Is there a difference on how these are calculated?

Scaling of the control limits

If the dataset contains a "large" autocorrelation the control limits might not describe the natural process limits [1]. Thus, we need to be able to scale the lower and upper control limits by using an external/user-defined scaling factor. This scaling factor should have the default value 1, so that by default no scaling is active.

Would it be a major issue to include this option?

Reference:
[1] Donald Wheeler: "Advanced Topics in Statistical Process Control", SPC Press, 1995; Chapter 12 "Control Charts for Autocorrelated Data".

qtukey error D5

Observed that when n > 100 I got a convergence error for D5. Unfortunately this causes problems with all the metrics because this one fails.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.