I'm working with physicians on a project to monitor compliance to proper dosage of antibiotics. To track the proportion of events that are not compliant, physicians like to use P charts
I would like to generate a P-Chart with 3 limit lines (corresponding to 1, 2, and 3 SDs) above and below the central line. I have not found a way to do this. I would also like the plot to have several breaks that separate the data into several time periods, which I can do in the qicharts package but not in other packages.
There are several packages for R for generating P Charts. The one I like most is qicharts. The standard P-Chart from qicharts, and all of the other packages I've seen, generates a plot with a Central Line and an Upper Control Limit and a Lower Control Limit at +3 and -3 SD from the central line.
I would like to figure out how to generate additional +1, +2, and -1, -2 SD control lines on the same plot. Some option such as
LimitLines = c(1, 2, 3) where the default is LimitlLines = 3
Here is the code, modified from r-projects, to generate data, create the chart, and include two breaks:
# Setup parameters
m.beds <- 300
m.stay <- 4
m.days <- m.beds * 7
m.discharges <- m.days / m.stay
p.pu <- 0.08
# Simulate data
discharges <- rpois(24, lambda = m.discharges)
patientdays <- round(rnorm(24, mean = m.days, sd = 100))
n.pu <- rpois(24, lambda = m.discharges * p.pu * 1.5)
n.pat.pu <- rbinom(24, size = discharges, prob = p.pu)
week <- seq(as.Date('2014-1-1'),
length.out = 24,
by = 'week')
# Combine data into a data frame
d <- data.frame(week, discharges, patientdays,n.pu, n.pat.pu)
# Create a P-chart to measure the number of patients with pressure ulcers (n.pat.pu) each week (week) as a proportion of all discharges (discharges) with breaks one third (8) and two thirds (16) of the way through the data
qic(n.pat.pu,
n = discharges,
x = week,
data = d,
chart = 'p',
multiply = 100,
breaks = c(8,16),
main = 'Hospital acquired pressure ulcers (P chart)',
ylab = 'Percent patients',
xlab = 'Week')