spccharter: spccharter

View source: R/spccharter.R

spccharterR Documentation

spccharter

Description

Finds all runs of desired length occurring on desired side of centre line. Can also find runs occurring on both sides of the line, though this is of limited use in terms of quality improvement. Re-bases centre line each time a run is discovered. The rebasing uses the points in the run, and a number of future points to ensure robust limits.

Usage

spccharter(
  df,
  numerator,
  denominator = NULL,
  datecol = NULL,
  by,
  plot_type = c("c", "p", "u"),
  runlength = 8,
  initial_rows = 25,
  look_forward = 25,
  direction = c("above", "below", "both"),
  round_digits = 2,
  multiplier = c(100, 1000, 10000),
  facet_cols = NULL,
  facet_scales = "fixed",
  chart_title = NULL,
  chart_subtitle = NULL,
  chart_caption = NULL,
  chart_breaks = NULL,
  line_colr = "#005EB8",
  line_size = 1.1,
  point_colr = "#005EB8",
  point_size = 2.7,
  centre_colr = "#06425AFF",
  centre_line_size = 1.05,
  highlight_fill = "#B50A2AFF",
  cl_fill = "grey80",
  cl_colr = NULL,
  wl_fill = "grey90",
  wl_colr = NULL,
  overwrite_theme = TRUE,
  outputs = c("both", "plot", "data"),
  ...
)

Arguments

df

data.frame or data table

numerator

numeric value representing the number of defect(s)

denominator

sample size

datecol

name of date column

by

a single unquoted variable or character vector oflength 2 indicating desired grouping variable(s) . You must supply a grouping variable .

plot_type

'c', 'p' or 'u' chart

runlength

length of desired run. Less than 8 may not be statisticall significant

initial_rows

number of points to calculate initial baseline mean

look_forward

number of rows to rebase limits on, including those in the sustained run

direction

should run occur "above", "below" or on "both" sides of the mean line

round_digits

the number of decimal places to round the p / u values and limits to

multiplier

to express results as rate per 1000, 10000 or for percentages

facet_cols

how many columns are required in the plot facets

facet_scales

defaults to "fixed". Alternatively, "free_y"

chart_title

title for the final chart

chart_subtitle

subtitle for chart

chart_caption

caption for chart

chart_breaks

character string defining desired x-axis date breaks

line_colr

colour for basic chart lines

line_size

thickness of connecting lines between run chart points

point_colr

colour for basic chart points

point_size

size of normal run chart points

centre_colr

colour for solid and extended mean lines

centre_line_size

thickness of solid and extended mean lines

highlight_fill

fill colour for highlighting points in a sustained run

cl_fill

geom_ribbon fill for upper and lower control limits

cl_colr

optional line colour for upper and lower control limits

wl_fill

geom_ribbon fill for upper and lower warning limits

wl_colr

optional line colour for upper and lower warning limits

overwrite_theme

set to FALSE if you want to amend the final plot afterwards, in which case it returns the default ggplot2 theme, gridlines and date labels. Leave at TRUE for theme_minimal, no gridlines and rotated date labels.

outputs

return both plot and data, plot only, data only

...

further arguments passed on to function

Details

Facets and axis limits are handled by ggplot, though x-axis breaks can be specified using the appropriate character string e.g. "3 months"

Value

(faceted) plot plus detailed data.tables showing improvement data. These outputs can be used for further processing in external tools

Examples


spccharter(testdata, numerator = defects, 
denominator = possible, datecol =  report_month,
by = testgroup, plot_type = 'p', 
direction = 'both', initial_rows = 13, 
look_forward = 13, chart_breaks = '3 months')

spccharter(testdata, numerator = defects, 
denominator = possible, datecol =  report_month,
by = testgroup, plot_type = 'c', 
direction = 'both', initial_rows = 13, 
look_forward = 13, chart_breaks = '3 months')






johnmackintosh/spccharter documentation built on March 16, 2023, 10:54 a.m.