Learn R Programming

NHSRwaitinglist

{NHSRwaitinglist} is an R package implementing the waiting list management approach described in the paper Understanding Waiting Lists Pressures by Fong et al (2022). The methodology is presented by Neil Walton, Professor in Operations Management at Durham University Business School. The package is being contributed to by members of the NHS-R Community, with the aim of making it simpler for NHS analysts to adopt these methods for the analysis of their own waiting lists.

Explanatory Videos

These videos explain more about the Operations Management methodologies which are encapsulated by the package. Click through to view them on YouTube.

Detailed presentation of methodRecap of method, and presentation of this package
Midlands Analyst Network Huddle, Nov 2023Health and Care Analytics Conference e-lab, Jul 2024

Installation

You can install the current version of {NHSRwaitinglist} from GitHub as below.
If you have not installed from GitHub before, you may first need to create and store a “Personal Access Token” (PAT) to grant access to your account, for example by following the {usethis} guide.

# Install from CRAN
install.packages("NHSRwaitinglist")

# install.packages("remotes")
remotes::install_github("nhs-r-community/NHSRwaitinglist", build_vignettes = TRUE)

Getting Started

There is a minimal example below. To look in more detail at the functions within the package and some more ways of using them, it is a good idea to review the first two vignettes:

  1. The example walkthrough vignette takes a step-by-step walk through the white paper, using the six core functions in this package.
  2. The three example waiting lists vignette simulates three closely related waiting lists, and uses package functions to explore some of their characteristics.

At its most basic, the package can be used to simulate a waiting list (a dataframe of waiting list addition dates and removal dates), and then compute some important statistics. Of course, if you already have waiting list data ready to analyse, you can skip the simulation step in the code below.

# load the package
library(NHSRwaitinglist)

# simulate a waiting list
waiting_list <- wl_simulator(
  start_date = "2020-01-01",
  end_date = "2024-03-31",
  demand = 10, # simulating 10 patient arrivals per week
  capacity = 10.2 # simulating 10.2 patients being treated per week
)

# compute some waiting list statistics
overall_stats <- wl_stats(
  waiting_list = waiting_list,
  target_wait = 18 # standard NHS 18wk target
)

# review the minimal dataset needed to define a waiting list (first 5 rows only)
knitr::kable(head(waiting_list, 5))
ReferralRemoval
2020-01-022020-01-03
2020-01-032020-01-04
2020-01-042020-01-05
2020-01-042020-01-06
2020-01-062020-01-07

# review the waiting list statistics
knitr::kable(overall_stats)
mean_demandmean_capacityloadload_too_bigcount_demandqueue_sizetarget_queue_sizequeue_too_bigmean_waitcv_arrivalcv_removaltarget_capacityrelief_capacitypressure
9.81806510.083720.9736549FALSE2174544.18129FALSE1.81.1317750.700378710.01489NA0.2

Contributing

If you want to learn more about this project, please join the discussion at the NHS-R Community Slack group and the specific channel #managing-waiting-lists.

Please see our guidance on how to contribute.

This project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

The simplest way to contribute is to raise an issue detailing the feature or functionality you would like to see added, or any unexpected behaviour or bugs you have experienced.

Pull-Request workflow

You are welcome to also submit Pull Requests and, as the main branch is protected and won’t accept pushes directly even if you have been added to the repository as a member, the workflow will be (from your own forked repository if you are not a member, or a clone of the repository if you are a member):

  • Create new branch with a descriptive name
  • Commit to the new branch (add code or delete code or make changes)
  • Push the commits
  • Create a pull-request in GitHub to signal that your work is ready to be merged
  • Tag one or more reviewers (@ThomUK and @ChrisMainey) so that your contribution can be reviewed and merged into main

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Jacqueline Grout

Copy Link

Version

Install

install.packages('NHSRwaitinglist')

Monthly Downloads

167

Version

0.1.2

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Chris Mainey

Last Published

July 15th, 2025

Functions in NHSRwaitinglist (0.1.2)

sim_schedule

Generator a list of dates to schedule
wl_queue_size

Queue size calculator
wl_insert

Insert new referrals into the waiting list
wl_referral_stats

Calculate some stats about referrals
wl_schedule

A simple operation scheduler
wl_simulator

Simple simulator to create a waiting list
wl_removal_stats

Calculate some stats about removals
wl_stats

Calculate some stats about the waiting list
calc_queue_load

Calculate Queue Load
calc_relief_capacity

Relief Capacity
calc_target_capacity

Target Capacity
opcs4

OPCS4 data
calc_target_mean_wait

Average Waiting Time
calc_target_queue_size

Target Queue Size
calc_waiting_list_pressure

Calculate Waiting List Pressure
create_waiting_list

Create Waiting List
sim_patients

Generator of NHS patients
wl_join

Join two waiting list
demographic_data

demographic data