A run chart is a simple analytical tool that helps us understand changes in data over time. - NHS Healthcare Improvement Scotland.
Run charts1 are non-trivial to automate. A number of solutions exist in the healthcare improvement community in Scotland. However the author is only aware of small-scale solutions such as scripts and Excel macros.
These kinds of approaches have the following limitations:
The runchart
package aims to overcome these limitations by exporting a single, well tested, function of the same name: runchart()
.
Install the package using like this:
# install.packages("devtools")
devtools::install_github('jsphdms/runchart')
For example:
Code for plotting the result might look like this:
There are several behaviours to notice in the plot above:
Rephasing for each sustained shift (9 consecutive points all above/below the baseline).
Shifts are identified (6 or more consecutive points all above/below the baseline).
Missing values are ignored. For example the 27th data point above is missing, which causes the rephased baseline to be longer than the first.
Non-useful observations are ignored. For example the 15th data point above lands exactly on the first baseline. Therefore it neither breaks nor contributes to the observed shift.
As defined by the NHS Scotland Quality Improvement Hub↩