-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
195 lines (134 loc) · 7.17 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# runcharter <img src="man/figures/logo.png" width="160px" align="right" />
Automated analysis and re-basing of run charts at scale.
Online documentation and vignettes : [https://johnmackintosh.github.io/runcharter/](https://johnmackintosh.github.io/runcharter/)
<!-- badges: start -->
[![R-CMD-check](https://github.com/johnmackintosh/runcharter/workflows/R-CMD-check/badge.svg)](https://github.com/johnmackintosh/runcharter/actions)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Coverage status](https://codecov.io/gh/johnmackintosh/runcharter/branch/master/graph/badge.svg)](https://codecov.io/github/johnmackintosh/runcharter?branch=master)
[![Render README](https://github.com/johnmackintosh/runcharter/actions/workflows/render-readme.yaml/badge.svg)](https://github.com/johnmackintosh/runcharter/actions/workflows/render-readme.yaml)
[![Codecov test coverage](https://codecov.io/gh/johnmackintosh/runcharter/branch/master/graph/badge.svg)](https://app.codecov.io/gh/johnmackintosh/runcharter?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/runcharter)](https://CRAN.R-project.org/package=runcharter)
[![CRAN
Downloads](https://cranlogs.r-pkg.org/badges/runcharter)](https://cran.r-project.org/package=runcharter)
[![Total
Downloads](https://cranlogs.r-pkg.org/badges/grand-total/runcharter)](https://cran.r-project.org/package=runcharter)
<!-- badges: end -->
## Installation
You can install the latest stable version from CRAN with:
```{r,cran-install, eval = FALSE}
install.packages("runcharter")
```
You can install the development version from github with:
```{r gh-installation, eval = FALSE}
# install.packages("remotes") # if not already installed
remotes::install_github("johnmackintosh/runcharter")
# to ensure the vignettes are built or ensure latest version is installed:
remotes::install_github("johnmackintosh/runcharter",
build_vignettes = TRUE)
```
The rationale for the package is to analyse multiple run charts at once.
More importantly, the package will identify a run of n successive points on the desired side of the median line, and will recalculate / rebase the median accordingly.
Each time a run occurs, the median will be rebased.
This helps to track improvements over time.
The default is to plot a faceted plot, allowing ggplot2 to handle the axis limits.
You can specify the number of columns in the faceted plot however, and you can also specify both the breaks for date labels on the x axis, and whether the y axis limits are fixed, or can vary by facet panel.
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.width = 8,
fig.height = 5
)
```
# Function arguments and defaults
A default run of 9 is specified as that is the length of run used by the IHI for its patient safety initiatives worldwide.
```{r, eval=FALSE}
library(runcharter)
runcharter(df = signals,
med_rows = 13,
runlength = 9,
direction = "below",
datecol = NULL,
grpvar = NULL,
yval = NULL,
facet_cols = NULL,
facet_scales = "fixed",
chart_title = NULL,
chart_subtitle = NULL,
chart_caption = NULL,
chart_breaks = NULL,
line_colr = "#005EB8", # blue
point_colr ="#005EB8", # blue
median_colr = "#E87722", # orange
highlight_fill = "#DB1884") # magenta
```
The function will return a plot and a summary table showing the original baseline medians, and any sustained runs of improvement beyond the baseline period.
```{r runs_below, fig.width = 8, fig.height= 5}
library(runcharter)
runcharter(signals,
direction = "below",
datecol = date,
grpvar = grp,
yval = y,
chart_title = "Runs identified",
chart_subtitle = "Runs below the median signalling improvement")
```
## Runs in both directions
The package allows for finding runs in both directions (above and below the median).
Generally, for improvement purposes, you would only need to identify runs in one direction at a time.
In other words, if you are trying to reduce adverse events, improvement will be evidenced with a run below the median. Therefore, you would not rebase the median if a run of points above the median was observed.
However, for longer term monitoring, it may be necessary to identify and 'reset' a median if a sustained deterioration in performance occurs. Ideally, you should move to using SPC charts for monitoring purposes.
```{r, runs_7_5_both_directions, fig.width = 8, fig.height= 5}
library(runcharter)
signals %>%
runcharter(med_rows = 7,
runlength = 5,
direction = "both",
datecol = date,
grpvar = grp,
yval = y,
chart_title = "Runs in both directions",
chart_subtitle = "Runs of 5, from median calculated over first 7 data points in each location")
```
## Design decisions and similar packages
This package makes no attempt to identify or highlight 'trends' (consecutively increasing or decreasing points) or shorter 'shifts' of runs below the median.
In 8 years of working with QI data, I very rarely see trends, and when they do appear, they tend to result after a period of process degradation, when the process begins to return back to its natural median state.
In addition, research by qicharts2 author Jacob Anhoej shows that the trend rule is not reliable. There are no plans to add tests to identify trends to the package.
However, analysts are often asked to apply all the run chart rules.
In this case, if you need to apply the rules for trend , and still have the ability to revise run chart medians, you should consider using [the runchart package by Joseph Adams](https://github.com/jsphdms/runchart).
[qicharts2](https://github.com/anhoej/qicharts2) creates run and SPC charts. These can be rebased, but you must specify when to do so. Also, the analysis is based on the author's own rules and not the rules typically used in healthcare (e.g. the rules promoted by the IHI).
## Turn off run chart analysis
You can avoid rebasing medians by setting 'runlength' to 0 (zero).
This will plot the runcharts with the original baseline medians, but no runs analysis will take place.
```{r medians_only, fig.width=8, fig.height=5}
library(runcharter)
signals %>%
runcharter(med_rows = 13,
runlength = 0,
datecol = date,
grpvar = grp,
yval = y,
direction = "both")
```
Similarly, you can plot basic line charts by setting 'med_rows' to 0 (zero)
```{r lines_only, fig.width=8, fig.height=5}
library(runcharter)
signals %>%
runcharter(med_rows = 0,
runlength = 9,
datecol = date,
grpvar = grp,
yval = y,
direction = "both")
```