## 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