Learn R Programming

ham (version 1.2.0)

plot.control: Shewhart control charts

Description

Graph X-bar charts, p-charts, and u-charts. This includes producing means center lines, 3-sigma upper and lower control limits. Users can also calculate values before and after an intervention to see if a change in the control process happened. Values are returned in a data frame.

Usage

# S3 method for control
plot(
  x,
  y = NULL,
  xlim = NULL,
  ylim = NULL,
  xlab = NULL,
  ylab = NULL,
  main = NULL,
  lwd = NULL,
  col = NULL,
  iname = NULL,
  icol = "black",
  trend = FALSE,
  trcol = "gray",
  tgt = NULL,
  tgtcol = "gray",
  tpline = NULL,
  tpcol = NULL,
  cex = 1,
  cex.lab = NULL,
  cex.axis = NULL,
  cex.main = NULL,
  cex.text = NULL,
  x.axis = NULL,
  y.axis = NULL,
  round.c = NULL,
  ...
)

Value

plot of Shewhart control charts: X-bar charts, p-charts, and u-charts with 3-sigma control limits.

Arguments

x

control object.

y

not currently used, default is NULL.

xlim

specify plot's x-axis limits with a 2 element numeric vector.

ylim

specify plot's y-axis limits with a 2 element numeric vector.

xlab

a character vector label for the x-axis.

ylab

a character vector label for the y-axis.

main

the main title of the plot.

lwd

select the line width.

col

a 2 element character vector to specify the 1) center line and 2) both control limit colors. Defaults to, if nothing selected, c("blue", "red").

iname

intervention name text as a single character vector. Defaults to "Intervention" if nothing is selected.

icol

specify intervention line color as a single character vector. Defaults to "black" if nothing is selected.

trend

a logical vector that adds an ordinary least squares trend line (i.e., simple linear regression line) when trend=TRUE. Default is FALSE.

trcol

select a color for the trend line. Default is 'gray'.

tgt

specify 1 or more values on the y-axis of where to add one or more horizontal target lines. Default is NULL.

tgtcol

select one or multiple colors for one or multiple target lines. Default is 'gray'.

tpline

add one or more time point vertical lines using x-axis values. Default is NULL (i.e., no lines).

tpcol

specify a color for the time point line, tpline. Default is NULL.

cex

A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default of 1.

cex.lab

The magnification to be used for x and y labels relative to the current setting of cex.

cex.axis

The magnification to be used for axis annotation relative to the current setting of cex.

cex.main

The magnification to be used for main titles relative to the current setting of cex.

cex.text

The magnification to be used for the iname text added into the plot relative to the current setting of 1.

x.axis

a vector of unique character or numeric values that makes up x-axis values to replace the time variable values. This will be most helpful if you prefer current calendar months/years instead of values starting at 1 (e.g., x.axis= sort(unique(data$Year)) for 1900-1999, not 1-100). Must have equal lengths for unique x.axis values and replaced values (i.e., nrow(x)). Default is NULL.

y.axis

a vector of unique character or numeric values that makes up y-axis values to replace the outcome variable values. This will be most helpful if your outcome needs to be converted such as rate per 1,000 patient days (e.g., y.axis= seq(min(x$HAI)*1000, max(x$HAI)*1000, length.out=nrow(x))). Must have equal lengths for unique y.axis values and replaced values (i.e., nrow(x)). Default is NULL.

round.c

an integer indicating the number of decimal places when rounding numbers such as for y.axis. Default is 2.

...

additional arguments.

References

Ryan, T. (2011). Statistical Methods for Quality Improvement, Third Edition. John Wiley & Sons, Inc. ISBN: 978-0-470-59074-4.

Examples

Run this code
## Hospital LOS and readmissions ##
# X-bar chart
spc_x <- control(x="los", time="month", data=hosprog, type="x", n.equal=TRUE)
# Basic X-bar chart
plot(spc_x)

# p-chart, using only the numerator (i.e., y=NULL). Specify unequal sample sizes
spc_p <- control(x="rdm30", time="month", data=hosprog, type="p", n.equal=FALSE)
# p-chart, adding target and time point lines
plot(spc_p, tgt=c(0,.25), tgtcol="green", ylim=c(0,0.4), tpline=c(4,8),
tpcol= c("yellow","black"))

# u-chart for infection rates with an intervention
spc_u <- control(x="HAI", y="PatientDays", time="Month", data=infections,
type="u", n.equal=FALSE, intervention=22)
# u-chart with trend lines, various graphing options, x.axis start at 2nd year
# and y.axis changed to show HAIs per 1,000 patient days
plot(spc_u, main="u-Chart: HAI per 1,000 Patient Days Pre/Post Intervention",
col=c("green","dodgerblue"), trend=TRUE, trcol="red", x.axis=c((1:41+12)), round.c=1,
y.axis=seq(min(spc_u$HAI)*1000, max(spc_u$HAI)*1000, length.out=nrow(spc_u)),
xlab="Months (starting at year 2)", icol="gray", lwd=2, cex=2,
cex.axis=1.1, cex.main=1.25, cex.text=1.25)

Run the code above in your browser using DataLab