setwd("~/Documents/workspace/R-project/qcc")
# libraries
library(qcc)
## Package 'qcc', version 2.6
## Type 'citation("qcc")' for citing this R package in publications.
# make 2 plots in 1 figure
par(mfrow=c(1,1))
# points have base value of 10 w/ normally distrubuted error
# platelets <- rep(300000, 100) + rnorm(100, mean=0, sd=50000)
# qcc(platelets, type="xbar.one", center=300000, add.stats=TRUE,
# title="1st Batch", xlab="i-th platelets detected")
# first 90 points have base value of 10 x/ normally distributed error,
# last 10 points have base value of 11 w/ normally distributed error
platelets <- c(rep(300000, 90), rep(400000, 10)) + rnorm(100, mean = 0, sd=50000)
qcc(platelets, type="xbar.one", center=300000, add.stats=TRUE,
title="2nd Batch", xlab="i-th platelets detected")

## List of 11
## $ call : language qcc(data = platelets, type = "xbar.one", center = 3e+05, add.stats = TRUE, title = "2nd Batch", xlab = "i-th platelets detected")
## $ type : chr "xbar.one"
## $ data.name : chr "platelets"
## $ data : num [1:100, 1] 240054 352311 344648 280400 332733 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:100] 240054 352311 344648 280400 332733 ...
## ..- attr(*, "names")= chr [1:100] "1" "2" "3" "4" ...
## $ sizes : int [1:100] 1 1 1 1 1 1 1 1 1 1 ...
## $ center : num 3e+05
## $ std.dev : num 54799
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 135604 464396
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
# example using holdout/test sets
# platelets <- rep(300000, 100) + rnorm(100, mean = 0, sd=50000)
# qcc(platelets, newdata=rep(300000, 10) + rnorm(10, mean=0, sd=50000),
# type="xbar.one", center=10, add.stats=TRUE,
# title="2nd Batch", xlab="i-th platelets detected")
# Shapiro-Wilkoxon test: N0= data has normal distribution.
# If p > 0.05, then normally distributed with 95% confidentiallity
shapiro.test(platelets)
##
## Shapiro-Wilk normality test
##
## data: platelets
## W = 0.97691, p-value = 0.07621