qcc.formula: Formula interface to qcc

Description Usage Arguments Value Examples

View source: R/qccOperations.R

Description

This function provides a simplified interface to the qcc function. The main goal is to remove the need for using the qcc groups function. This allows for much simpler use of the function within piping functions/map.

Usage

1

Arguments

formula

a formula describing the outcome variable and the grouping variable

data

a data frame

type

a character string specifying the group statistics to compute.
Available methods are:

Statistic charted Chart description
"xbar" mean means of a continuous process variable
"R" range ranges of a continuous process variable
"S" standard deviation standard deviations of a continuous variable
"xbar.one" mean one-at-time data of a continuous process variable
"p" proportion proportion of nonconforming units
"np" count number of nonconforming units
"c" count nonconformities per unit
"u" count average nonconformities per unit
"g" count number of non-events between events

Furthermore, a user specified type of chart, say "newchart", can be provided. This requires the definition of "stats.newchart", "sd.newchart", and "limits.newchart". As an example, see stats.xbar.

plot

logical. If TRUE a Shewhart chart is plotted.

cutoff

a cutoff date for new data

...

further arguments passed to qcc:qcc()

Value

a qcc object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data("pistonrings", package = 'qcc')
diameter <- qcc::qcc.groups(pistonrings$diameter, pistonrings$sample)

# Without Cutoff
qcc_obj <- qcc::qcc(diameter[1:25,], type="xbar")
qcc_obj2 <- qcc.formula(diameter ~ sample, data = dplyr::filter(pistonrings, sample <= 25), type = "xbar", plot = TRUE)

# With Cutoff
qcc_new <-  qcc::qcc(diameter[1:25,], newdata = diameter[24:40,], type="xbar")
qcc_new2 <- qcc.formula(diameter ~ sample, data = pistonrings, type = "xbar", plot = TRUE, cutoff = 25)

# Dates and p chart
## use POSIXct, not Date object to create date
start <- as.POSIXct('2017-01-01')
end <- as.POSIXct('2017-01-15')
samp_dates <- seq(from = start, to = end, length.out = 15)
samp_dates <- sample(samp_dates, 100, replace = TRUE)
old_process <- samp_dates < '2017-01-08'
vals <- ifelse(old_process,rbinom(sum(old_process), 1 , p = 0.5), rbinom(sum(!old_process), 1,  p = 0.2) )
d <- data.frame(samp_dates, vals)

## Run the graphs with plot = TRUE
qcc.formula(vals ~ samp_dates, data = d, type = "p", plot = TRUE)
qcc.formula(vals ~ samp_dates, data = d, type = "p", plot = TRUE, cutoff = '2017-01-08')

West-End-Statistics/r-library-vakdr documentation built on Dec. 18, 2021, 7:16 p.m.