2

I have qcc chart that is working, but I would like to show the true dates for the values in the control chart instead of showing the value index number

I came across the post below, but I have been unable to apply it to my code. Adding line to plot in qcc Control Chart

Below is my R QCC code:

install.packages("qcc")
install.packages("ggQC")    
library(qcc)
library(ggQC)


date= seq(as.Date("2000/1/1"), by = "month", length.out = 20)
values = c( 
  2.92,    3.16,    2.88,    2.90,    2.92,
  2.94,    2.96,    2.98,    3.02,    2.67,
  3.09,    3.07,    3.04,    3.06,    3.05,
  3.03,    3.07,    2.91,    3.07,    3.30
)

exampl_data <- data.frame(ScrewID , values)
str(exampl_data)

qcc(exampl_data$values, type = "xbar.one", plot = True)

I would like the x axis of the qcc chart to display the dates in the format "jan-2019"/mmyy.

Thank you

henry
  • 31
  • 3

1 Answers1

2

Group labels can be added to a qcc plot by providing the labels argument.

Since you did not share the contents of ScrewID, I'm using date as the first observation:

> exampl_data <- data.frame(date , values)
> exampl_data
         date values
1  2000-01-01   2.92
2  2000-02-01   3.16
3  ...

The following code produces the plot below:

qcc(exampl_data$values,
  labels = format(exampl_data$date, "%b-%Y"),
  type = "xbar.one")

enter image description here

Optionally, use axes.las to change the labels' text orientation (note that due to the limited space, I removed the x axis label with xlab = ""):

qcc(exampl_data$values,
  labels = format(exampl_data$date, "%b-%Y"),
  type = "xbar.one",
  axes.las = 2,
  xlab = "")

enter image description here

David
  • 3,392
  • 3
  • 36
  • 47