knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "plots/README-"
)

ccharter

Control Charts made easy. ccharter focus on calculating control systems in a series and plotting them as an overlay to it.

Installation

Using ccharter

The ccharter package comes with two main functions:

Loading the package

library(ccharter)

Calculating the Control Systems points

# Create a random time series
set.seed(154)
time.series <- data.frame(t.dates = seq.Date(as.Date("2014-02-01"), as.Date("2016-08-01"), "month"),
               t.values = c(
               seq(0.1, 0.8, by = 0.1) * runif(8) + 3,
               seq(0.1, 0.7, by = 0.1) * runif(7) + 4,
               seq(0.1, 0.7, by = 0.1) * runif(7) + 5,
               seq(0.1, 0.4, by = 0.1) * runif(4) + 4,
               seq(0.1, 0.5, by = 0.1) * runif(5) + 4)
               )

# Execute function
control.chart.data <- ccpoints(time.series, "t.dates", "t.values")

If we inspect the object we may find it's a list consisting in the following elements:

  1. The input time series along with the calculated mean and sd for each system
  2. The name of the dates column
  3. The name of the values column
  4. The count of systems result
  5. The summary of missing values removed
  6. The reference point of last break
  7. The weeks since last break (if date values were provided)
  8. The next break expectation, above or below of current system
  9. The points remaining for a new system break
# Inspecting cchart object content
lapply(control.chart.data, head)

To extract the data frame, we can access it from the list in the following way:

control.chart.data[["data"]]

Plotting the Control Systems points

This is how the example series looks like:

g <- ggplot2::ggplot(control.chart.data[["data"]], ggplot2::aes(x = t.dates))

#g <- g + ggplot2::geom_line(ggplot2::aes(y = data.mean), size = 1.2, color = "darkorange")
#g <- g + ggplot2::geom_line(ggplot2::aes(y = data.ll), size = 1.2, color = "steelblue")
#g <- g + ggplot2::geom_line(ggplot2::aes(y = data.ul), size = 1.2, color = "steelblue")

g <- g + ggplot2::geom_line(ggplot2::aes(y = t.values), size=0.7, color = "gray44")
g <- g + ggplot2::geom_point(ggplot2::aes(y = t.values), color = "midnightblue")

g <- g + ggplot2::theme_bw()
g <- g + ggplot2::scale_x_date(labels = scales::date_format("%b/%y"), minor_breaks = NULL, breaks = scales::date_breaks("month"))
g <- g + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, hjust = 1))
g <- g + ggplot2::labs(x = "Month")
g <- g + ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0))
print(g)
# Passing the cchart object to the cc2plot function
cc2plot(control.chart.data)

For detailed functions documentation you can access the help files in R with ?ccpoints and ?cc2plot.

Integration with KNIME: ccharter

Here you may find a brief guide on how to integrate the package in a KNIME workflow.



jbaxx/ccharter documentation built on Feb. 27, 2021, 9:10 p.m.