Forum Discussion
R Control Chart
Thanks Ted, this is along the same lines, but I am interested more in an "xbar" chart and also looking for a simple R script to create a Pareto chart for my customers.
Thank you for the scripts for the Histogram and Bar Plot, I will also be adding this to my arsenal.
RE: also looking for a simple R script to create a Pareto chart
In order to use any chart -that is part of a R Visualization package library - it's logical to first make sure it's installed.
install.packages('<yourPackage>')
Now considering the huge amount of R package visualization libraries, there may be a few ways to reproduce what you want. Note that I don't consider myself an R guru at this stage, still here's a couple of basic samples.
qcc library...
library(qcc)
defect <- c(80, 27, 66, 94, 33)
names(defect) <- c("price code", "schedule date", "supplier code", "contact num.", "part num.")
pareto.chart(defect, ylab = "Error frequency", col=heat.colors(length(defect)))ggplot2 library...
library(ggplot2)
counts <- c(80, 27, 66, 94, 33)
defects <- c("price code", "schedule date", "supplier code", "contact num.", "part num.")
dat <- data.frame(
count = counts,
defect = defects,
stringsAsFactors=FALSE
)
dat <- dat[order(dat$count, decreasing=TRUE), ]
dat$defect <- factor(dat$defect, levels=dat$defect)
dat$**bleep** <- cumsum(dat$count)
dat
ggplot(dat, aes(x=defect)) +
geom_bar(aes(y=count), fill="blue", stat="identity") +
geom_point(aes(y=**bleep**)) +
geom_path(aes(y=**bleep**, group=1))
I haven't played much with x-Bar chart though I'll check if I can find something... Anyway hope this helps