vec1<-c(1,2,3,4)
vec2<-c("dog","cat","bird","hamster")
vec3<-c(1,-1,1,-1)
df<-data.frame(vec1,vec2,vec3)
library(readxl)
## Warning: package 'readxl' was built under R version 4.3.3
df<-read.csv("C:/Users/rgale/Downloads/DoEstuff/SoftDrinkDeliveryTime.csv")
hist(df$DeliveryTime.min)

hist(df$DeliveryTime.min., main="History of Delivery Times",xlab="Minutes", ylab="Frequency (count)")

plot(df$NumCases)

plot(df$NumCases,xlab="day",ylab="number delivered",main="Number of Cases Delivered by Day")

boxplot(df$DeliveryTime.min)

boxplot(df$DeliveryTime.min.,df$Distance.ft.)

boxplot(df$DeliveryTime.min.,df$Distance.ft., names=c("minutes","feet"))

boxplot(df$DeliveryTime.min.,df$Distance.ft., names=c("minutes","feet"),main="Boxplot of delivery times and distance")

plot(df$DeliveryTime.min.,df$Distance.ft.)
abline(lm(df$Distance.ft~df$DeliveryTime.min.))

cor(df$DeliveryTime.min, df$Distance.ft)
## [1] 0.8916701
cor(df)
## Observation DeliveryTime.min. NumCases Distance.ft.
## Observation 1.00000000 0.1183848 0.2352871 0.08219059
## DeliveryTime.min. 0.11838477 1.0000000 0.9646146 0.89167008
## NumCases 0.23528713 0.9646146 1.0000000 0.82421500
## Distance.ft. 0.08219059 0.8916701 0.8242150 1.00000000
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.3.3
## corrplot 0.92 loaded
corrplot(cor(df))

corrplot(cor(df),type="upper",method="number")

retro<-read.csv("C:/Users/rgale/Downloads/DoEstuff/diameter_retrospec_qc.xlsx")
online<-read.csv("C:/Users/rgale/Downloads/DoEstuff/diameter_online_qc.xlsx")
library(qcc)
## Warning: package 'qcc' was built under R version 4.3.3
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
qcc(retro,type="xbar")

## List of 11
## $ call : language qcc(data = retro, type = "xbar")
## $ type : chr "xbar"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:26] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 74
## $ std.dev : num 0.00974
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(retro,type="xbar",newdata=online)

## List of 15
## $ call : language qcc(data = retro, type = "xbar", newdata = online)
## $ type : chr "xbar"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:26] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 74
## $ std.dev : num 0.00974
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "27" "28" "29" "30" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## $ newdata.name: chr "online"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
q<-qcc(retro, type="xbar",newdata=online, plot=FALSE)
plot(q,chart.all=FALSE)

qcc(retro,type="xbar",newdata=online,nsigmas=2)

## List of 15
## $ call : language qcc(data = retro, type = "xbar", newdata = online, nsigmas = 2)
## $ type : chr "xbar"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:26] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 74
## $ std.dev : num 0.00974
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "27" "28" "29" "30" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## $ newdata.name: chr "online"
## $ nsigmas : num 2
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(retro,type="xbar",newdata=online,confidence.level=0.99)

## List of 15
## $ call : language qcc(data = retro, type = "xbar", newdata = online, confidence.level = 0.99)
## $ type : chr "xbar"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:26] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 74
## $ std.dev : num 0.00974
## $ newstats : Named num [1:15] 74 74 74 74 74 ...
## ..- attr(*, "names")= chr [1:15] "27" "28" "29" "30" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## $ newdata.name : chr "online"
## $ confidence.level: num 0.99
## $ limits : num [1, 1:2] 74 74
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(retro, type="R")

## List of 11
## $ call : language qcc(data = retro, type = "R")
## $ type : chr "R"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:26] 0.038 0.019 0.036 0.022 0.026 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 0.0227
## $ std.dev : num 0.00974
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0479
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(retro, type="R",newdata=online)

## List of 15
## $ call : language qcc(data = retro, type = "R", newdata = online)
## $ type : chr "R"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:26] 0.038 0.019 0.036 0.022 0.026 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 0.0227
## $ std.dev : num 0.00974
## $ newstats : Named num [1:15] 0.044 0.025 0.015 0.019 0.017 ...
## ..- attr(*, "names")= chr [1:15] "27" "28" "29" "30" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## $ newdata.name: chr "online"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0479
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
qcc(retro, type="S")

## List of 11
## $ call : language qcc(data = retro, type = "S")
## $ type : chr "S"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics: Named num [1:26] 0.01477 0.0075 0.01475 0.00908 0.01222 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 0.0092
## $ std.dev : num 0.00979
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0192
## ..- attr(*, "dimnames")=List of 2
## $ violations:List of 2
## - attr(*, "class")= chr "qcc"
qcc(retro, type="S",newdata=online)

## List of 15
## $ call : language qcc(data = retro, type = "S", newdata = online)
## $ type : chr "S"
## $ data.name : chr "retro"
## $ data : num [1:26, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ statistics : Named num [1:26] 0.01477 0.0075 0.01475 0.00908 0.01222 ...
## ..- attr(*, "names")= chr [1:26] "1" "2" "3" "4" ...
## $ sizes : int [1:26] 5 5 5 5 5 5 5 5 5 5 ...
## $ center : num 0.0092
## $ std.dev : num 0.00979
## $ newstats : Named num [1:15] 0.01655 0.01033 0.00691 0.0075 0.00673 ...
## ..- attr(*, "names")= chr [1:15] "27" "28" "29" "30" ...
## $ newdata : num [1:15, 1:5] 74 74 74 74 74 ...
## ..- attr(*, "dimnames")=List of 2
## $ newsizes : int [1:15] 5 5 5 5 5 5 5 5 5 5 ...
## $ newdata.name: chr "online"
## $ nsigmas : num 3
## $ limits : num [1, 1:2] 0 0.0192
## ..- attr(*, "dimnames")=List of 2
## $ violations :List of 2
## - attr(*, "class")= chr "qcc"
q=qcc(retro,type="xbar",newdata=online,plot=FALSE)
(warn.limits<-limits.xbar(q$center,q$std.dev,q$sizes,2))
## LCL UCL
## 73.99147 74.00889
plot(q,restore.par=FALSE)
abline(h=warn.limits,lty=3,col="chocolate")
