% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.control.R
\name{plot.control}
\alias{plot.control}
\title{Shewhart control charts}
\usage{
\method{plot}{control}(
  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,
  ...
)
}
\arguments{
\item{x}{control object.}

\item{y}{not currently used, default is NULL.}

\item{xlim}{specify plot's x-axis limits with a 2 element numeric vector.}

\item{ylim}{specify plot's y-axis limits with a 2 element numeric vector.}

\item{xlab}{a character vector label for the x-axis.}

\item{ylab}{a character vector label for the y-axis.}

\item{main}{the main title of the plot.}

\item{lwd}{select the line width.}

\item{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").}

\item{iname}{intervention name text as a single character vector. Defaults to "Intervention" if nothing is selected.}

\item{icol}{specify intervention line color as a single character vector. Defaults to "black" if nothing is selected.}

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

\item{trcol}{select a color for the trend line. Default is 'gray'.}

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

\item{tgtcol}{select one or multiple colors for one or multiple target lines. Default is 'gray'.}

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

\item{tpcol}{specify a color for the time point line, tpline. Default is NULL.}

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

\item{cex.lab}{The magnification to be used for x and y labels relative to the current setting of cex.}

\item{cex.axis}{The magnification to be used for axis annotation relative to the current setting of cex.}

\item{cex.main}{The magnification to be used for main titles relative to the current setting of cex.}

\item{cex.text}{The magnification to be used for the iname text added into the plot relative to the current setting of 1.}

\item{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.}

\item{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.}

\item{round.c}{an integer indicating the number of decimal places when rounding numbers such as for y.axis.
Default is 2.}

\item{...}{additional arguments.}
}
\value{
plot of Shewhart control charts: X-bar charts, p-charts, and u-charts with 3-sigma control limits.
}
\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.
}
\examples{
## 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)
}
\references{
Ryan, T. (2011). Statistical Methods for Quality Improvement, Third Edition.
John Wiley & Sons, Inc. ISBN: 978-0-470-59074-4.
}
