| Title: | Waiting List Metrics Using Queuing Theory |
|---|---|
| Description: | Waiting list management using queuing theory to analyse, predict and manage queues, based on the approach described in Fong et al. (2022) <doi:10.1101/2022.08.23.22279117>. Aimed at UK National Health Service (NHS) applications, waiting list summary statistics, target-value calculations, waiting list simulation, and scheduling functions are included. |
| Authors: | Neil Walton [aut] (ORCID: <https://orcid.org/0000-0002-5241-9765>), Jacqueline Grout [ctb], Zoë Turner [ctb] (ORCID: <https://orcid.org/0000-0003-1033-9158>), Matt Dray [aut], Paul Fenton [ctb], Peter Shakeshaft [ctb], David Foord [ctb], Tom Smith [aut], Chris Mainey [cre, aut] (ORCID: <https://orcid.org/0000-0002-3018-6171>), Mohammed Mohammed [ctb], NHS-R community [cph] |
| Maintainer: | Chris Mainey <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-05-13 07:04:17 UTC |
| Source: | https://github.com/nhs-r-community/NHSRwaitinglist |
Calculates the queue load. The queue load is the number of arrivals that occur for every patient leaving the queue (given that the waiting list did not empty). It could also be described as the rate of service at the queue. The queue load is calculated by dividing the demand by the capacity: queue_load = demand / capacity.
calc_queue_load(demand, capacity)calc_queue_load(demand, capacity)
demand |
Numeric value of rate of demand in same units as target wait - e.g. if target wait is weeks, then demand in units of patients/week. |
capacity |
Numeric value of the number of patients that can be served (removals) from the waiting list each week. |
Numeric value of load which is the ratio between demand and capacity.
# If 30 patients are added to the waiting list each week (demand) and 27 # removed (capacity) this results in a queue load of 1.11 (30/27). calc_queue_load(30, 27)# If 30 patients are added to the waiting list each week (demand) and 27 # removed (capacity) this results in a queue load of 1.11 (30/27). calc_queue_load(30, 27)
Calculates required relief capacity to achieve target queue size in a given period of time as a function of demand, queue size, target queue size and time period. Relief Capacity is required if Queue Size > 2 * Target Queue Size.
Relief Capacity = Current Demand + (Queue Size - Target Queue Size)/Time Steps
WARNING!: make sure units match. I.e. if demand is measured per week then time_to_target should be weeks or if demand is per day then time_to_target is per day
calc_relief_capacity( demand, queue_size, target_queue_size, time_to_target = 26, num_referrals = 0, cv_demand = 0 )calc_relief_capacity( demand, queue_size, target_queue_size, time_to_target = 26, num_referrals = 0, cv_demand = 0 )
demand |
Numeric value of rate of demand in same units as target wait e.g. if target wait is weeks, then demand in units of patients/week. |
queue_size |
Numeric value of current number of patients in queue. |
target_queue_size |
Numeric value of desired number of patients in queue. |
time_to_target |
Numeric value of desired number of time-steps to reach the target queue size by. |
num_referrals |
Numeric value of the number of referrals per time step. |
cv_demand |
To be completed |
A numeric value of the required rate of capacity to achieve a target queue size in a given period of time.
# If demand is 30 patients per week, the current queue size is 1200 and the # target is to achieve a queue size of 390 in 26 weeks, then # Relief Capacity = 30 + (1200 - 390)/26 = 61.15 patients per week. calc_relief_capacity(30, 1200, 390, 26)# If demand is 30 patients per week, the current queue size is 1200 and the # target is to achieve a queue size of 390 in 26 weeks, then # Relief Capacity = 30 + (1200 - 390)/26 = 61.15 patients per week. calc_relief_capacity(30, 1200, 390, 26)
Applies Kingman/Marchal's Formula :
capacity = demand + (cvd**2 + cvc**2) / waiting_time
where cvd = coefficient of variation of time between arrivals cvd = coefficient of variation of service times waiting_time = target_wait / factor
calc_target_capacity( demand, target_wait, factor = 4, cv_demand = 1, cv_capacity = 1 )calc_target_capacity( demand, target_wait, factor = 4, cv_demand = 1, cv_capacity = 1 )
demand |
Numeric value of rate of demand in same units as target wait e.g. if target wait is weeks, then demand in units of patients/week. |
target_wait |
Numeric value of number of weeks that has been set as the target within which the patient should be seen. |
factor |
the amount we divide the target by in the waiting list e.g. if target is 52 weeks the mean wait should be 13 for a factor of 4 |
cv_demand |
coefficient of variation of time between arrivals |
cv_capacity |
coefficient of variation between removals due to operations completed |
numeric. The capacity required to achieve a target waiting time.
demand <- 4 # weeks target_wait <- 52 # weeks # number of operations per week to have mean wait of 52/4 calc_target_capacity(demand, target_wait)demand <- 4 # weeks target_wait <- 52 # weeks # number of operations per week to have mean wait of 52/4 calc_target_capacity(demand, target_wait)
This calculates the target mean wait given the two inputs of target_wait and a numerical value for factor. The average wait is actually the target mean wait and is calculated as follows: target_wait / factor. If we want to have a chance between 1.8%-0.2% of making a waiting time target, then the average patient should have a waiting time between a quarter and a sixth of the target. Therefore: The mean wait should sit somewhere between target_wait/factor=6 < Average Waiting Time < target_wait/factor=4.
calc_target_mean_wait(target_wait, factor = 4)calc_target_mean_wait(target_wait, factor = 4)
target_wait |
Numeric value of the number of weeks that has been set as the target within which the patient should be seen. |
factor |
Numeric factor used in average wait calculation - to get a quarter of the target use factor=4 and one sixth of the target use factor = 6 etc. Defaults to 4. |
Numeric value of target mean waiting time to achieve a given target wait.
# If the target wait is 52 weeks then the target mean wait with a factor of 4 # would be 13 weeks and with a factor of 6 it would be 8.67 weeks. calc_target_mean_wait(52, 4)# If the target wait is 52 weeks then the target mean wait with a factor of 4 # would be 13 weeks and with a factor of 6 it would be 8.67 weeks. calc_target_mean_wait(52, 4)
Uses Little's Law to calculate the target queue size to achieve a target waiting time as a function of observed demand, target wait and a variability factor used in the target mean waiting time calculation.
Target Queue Size = Demand * Target Wait / 4.
The average wait should sit somewhere between target_wait/factor=6 < Average Waiting Time < target_wait/factor=4 The factor defaults to 4.
Only applicable when Capacity > Demand.
calc_target_queue_size(demand, target_wait, factor = 4)calc_target_queue_size(demand, target_wait, factor = 4)
demand |
Numeric value of rate of demand in same units as target wait e.g. if target wait is weeks, then demand in units of patients/week. |
target_wait |
Numeric value of number of weeks that has been set as the target within which the patient should be seen. |
factor |
Numeric factor used in average wait calculation
|
Numeric target queue length.
# If demand is 30 patients per week and the target wait is 52 weeks, then the # Target queue size = 30 * 52/4 = 390 patients. calc_target_queue_size(30, 52, 4)# If demand is 30 patients per week and the target wait is 52 weeks, then the # Target queue size = 30 * 52/4 = 390 patients. calc_target_queue_size(30, 52, 4)
For a waiting list with target waiting time, the pressure on the waiting list is twice the mean delay divided by the waiting list target. The pressure of any given waiting list should be less than 1. If the pressure is greater than 1 then the waiting list is most likely going to miss its target. The waiting list pressure is calculated as follows: pressure = 2 * mean_wait / target_wait.
calc_waiting_list_pressure(mean_wait, target_wait)calc_waiting_list_pressure(mean_wait, target_wait)
mean_wait |
Numeric value of target mean waiting time to achieve a given target wait. |
target_wait |
Numeric value of the number of weeks that has been set as the target within which the patient should be seen. |
Numeric value of wait_pressure which is the waiting list pressure.
calc_waiting_list_pressure(63, 52)calc_waiting_list_pressure(63, 52)
Creates a waiting list using the parameters specified
create_waiting_list( n, mean_arrival_rate, mean_wait, start_date = Sys.Date(), limit_removals = TRUE, sd = 0, rott = 0, ... )create_waiting_list( n, mean_arrival_rate, mean_wait, start_date = Sys.Date(), limit_removals = TRUE, sd = 0, rott = 0, ... )
n |
Numeric value of rate of demand in same units as target wait
|
mean_arrival_rate |
Numeric value of mean daily arrival rate. |
mean_wait |
Numeric value of mean wait time for treatment/on waiting list. |
start_date |
Character value of date from which to start generated waiting list. |
limit_removals |
Defaults to TRUE |
sd |
Numeric value, standard deviation. Defaults to 0. |
rott |
Numeric value, proportion of referrals to be randomly flagged as ROTT. Defaults to 0. |
... |
Container for the list |
A tibble with randomly generated patient records and the following columns:
Integer. Unique identifier for the patient.
Date. The date the patient was added to the waiting list.
Date. The date the patient was removed from the waiting list.
Numeric. Number of days between the addition and removal dates.
Logical. Whether the removal was for reasons other than treatment (ROTT).
Additional columns may be included if supplied via ...,
where named vectors (e.g., patient-level variables) of compatible length
are merged into the output tibble.
create_waiting_list(366, 50, 21, "2024-01-01", 10, 0.1)create_waiting_list(366, 50, 21, "2024-01-01", 10, 0.1)
demographic data
data(demographic_data)data(demographic_data)
Data frame with 9 columns
ODS hospital site code
Others to do with file is updated
data(demographic_data)data(demographic_data)
OPCS4 data
data(opcs4)data(opcs4)
Data frame with 9 columns
The first digit of the OPCS4 code, or 'chapter'
The name/group of 'chapter' of the OPCS4 code
Others to do with file is updated
https://biobank.ndph.ox.ac.uk/ukb/coding.cgi?id=240
data(opcs4)data(opcs4)
Generates simulated NHS patients
sim_patients(n_rows = 10, start_date = NULL)sim_patients(n_rows = 10, start_date = NULL)
n_rows |
Number of rows/patients to generate |
start_date |
Start date (needed to generate patient ages) |
A data.frame representing an empty waiting list with the following columns:
Date. Referral date; all values are NA.
Date. Removal date; all values are NA.
Date. Patient withdrawal date; all values are
NA
Numeric. Waiting list priority level, from 1 (most urgent) to 4 (least urgent).
Numeric. Target number of days the patient should wait at the assigned priority level (e.g., 28 days for priority 2)
Character. Patient name in the format
"Last, First".
Date. Date of birth.
Integer. Patient identifier, up to 100,000,000.
Character. One-letter code representing the specialty of the procedure.
Character. Full name of the specialty associated with the procedure.
Character. OPCS-4 code of the selected procedure.
Character. Name of the selected procedure.
Character. Consultant name in the format
"Last, First".
sim_patients()sim_patients()
Generates a list if dates in a given range
sim_schedule(n_rows = 10, start_date = NULL, daily_capacity = 1)sim_schedule(n_rows = 10, start_date = NULL, daily_capacity = 1)
n_rows |
Number of rows/patients to generate |
start_date |
Start date (needed to generate patient ages) |
daily_capacity |
Number of patients per day |
A vector of Date values representing scheduled procedure
dates. The length of the vector is equal to n_rows, and the dates
are spaced according to the specified daily_capacity.
Adds new referrals, with other columns set as NA.
wl_insert(waiting_list, additions, referral_index = 1)wl_insert(waiting_list, additions, referral_index = 1)
waiting_list |
data.frame. A df of referral dates and removals |
additions |
Date or character vector (in format 'YYYY-MM-DD'). A list of referral dates to add to the waiting list |
referral_index |
The index of the column in |
A data.frame representing the updated waiting list,
with additional referrals dates in the column specified by
referral_index. Other columns are filled with NA in the
new rows. The result is sorted by the referral column.
referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) additions <- c.Date("2024-01-03", "2024-01-05", "2024-01-18") longer_waiting_list <- wl_insert(waiting_list, additions)referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) additions <- c.Date("2024-01-03", "2024-01-05", "2024-01-18") longer_waiting_list <- wl_insert(waiting_list, additions)
Take two waiting list and sorting in date order
wl_join(wl_1, wl_2, referral_index = 1)wl_join(wl_1, wl_2, referral_index = 1)
wl_1 |
a waiting list: dataframe consisting addition and removal dates |
wl_2 |
a waiting list: dataframe consisting addition and removal dates |
referral_index |
the column index where referrals are listed |
A data.frame representing the combined waiting list, created by
joining wl_1 and wl_2. The result is sorted by the referral
date column specified by referral_index. The column structure is
preserved from the input data frames.
referrals <- c.Date("2024-01-01","2024-01-04","2024-01-10","2024-01-16") removals <- c.Date("2024-01-08",NA,NA,NA) wl_1 <- data.frame("referral" = referrals ,"removal" = removals ) referrals <- c.Date("2024-01-04","2024-01-05","2024-01-16","2024-01-25") removals <- c.Date("2024-01-09",NA,"2024-01-19",NA) wl_2 <- data.frame("referral" = referrals ,"removal" = removals ) wl_join(wl_1,wl_2)referrals <- c.Date("2024-01-01","2024-01-04","2024-01-10","2024-01-16") removals <- c.Date("2024-01-08",NA,NA,NA) wl_1 <- data.frame("referral" = referrals ,"removal" = removals ) referrals <- c.Date("2024-01-04","2024-01-05","2024-01-16","2024-01-25") removals <- c.Date("2024-01-09",NA,"2024-01-19",NA) wl_2 <- data.frame("referral" = referrals ,"removal" = removals ) wl_join(wl_1,wl_2)
Calculates queue sizes from a waiting list
wl_queue_size( waiting_list, start_date = NULL, end_date = NULL, referral_index = 1, removal_index = 2 )wl_queue_size( waiting_list, start_date = NULL, end_date = NULL, referral_index = 1, removal_index = 2 )
waiting_list |
data.frame consisting addition and removal dates |
start_date |
Date or character (in format 'YYYY-MM-DD'); start of calculation period |
end_date |
Date or character (in format 'YYYY-MM-DD'); end of calculation period |
referral_index |
the index of referrals in waiting_list |
removal_index |
the index of removals in waiting_list |
A data.frame containing the size of the waiting list for each day in
the specified date range. If start_date and/or end_date are
NULL, the function uses the earliest and latest referral dates in
the input data.frame. The returned data.frame has the following columns:
Date. Each date within the computed range, starting from the first referral.
Numeric. Number of patients on the waiting list on that date.
referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) wl_queue_size(waiting_list)referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) wl_queue_size(waiting_list)
Calculate some stats about referrals
wl_referral_stats( waiting_list, start_date = NULL, end_date = NULL, referral_index = 1 )wl_referral_stats( waiting_list, start_date = NULL, end_date = NULL, referral_index = 1 )
waiting_list |
data.frame. A df of referral dates and removals |
start_date |
Date or character (in format 'YYYY-MM-DD'); The start date to calculate from |
end_date |
Date or character (in format 'YYYY-MM-DD'); The end date to calculate to |
referral_index |
the column index of referrals |
A data.frame with the following summary statistics on referrals/demand:
Numeric. Mean number of additions to the waiting list per week.
Numeric. Mean number of additions to the waiting list per day.
Numeric. Coefficient of variation in the time between additions to the waiting list.
Numeric. Total demand over the full time period.
referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) referral_stats <- wl_referral_stats(waiting_list)referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) referral_stats <- wl_referral_stats(waiting_list)
Calculate some stats about removals
wl_removal_stats( waiting_list, start_date = NULL, end_date = NULL, referral_index = 1, removal_index = 2 )wl_removal_stats( waiting_list, start_date = NULL, end_date = NULL, referral_index = 1, removal_index = 2 )
waiting_list |
data.frame. A df of referral dates and removals |
start_date |
Date or character (in format 'YYYY-MM-DD'); The start date to calculate from. |
end_date |
Date or character (in format 'YYYY-MM-DD'); The end date to calculate to. |
referral_index |
Index of the referral column in waiting_list. |
removal_index |
Index of the removal column in waiting_list. |
A data.frame with the following summary statistics on removals/capacity:
Numeric. Mean number of removals from the waiting list per week.
Numeric. Mean number of removals from the waiting list per day.
Numeric. Coefficient of variation in the time between removals from the waiting list.
Numeric. Total number of removals from the waiting list over the full time period.
referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) removal_stats <- wl_removal_stats(waiting_list)referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) removal_stats <- wl_removal_stats(waiting_list)
Takes a list of dates and schedules them to a waiting list, by adding a removal date to the data.frame. This is done in referral date order, I.e. earlier referrals are scheduled first (FIFO).
wl_schedule( waiting_list, schedule, referral_index = 1, removal_index = 2, unscheduled = FALSE )wl_schedule( waiting_list, schedule, referral_index = 1, removal_index = 2, unscheduled = FALSE )
waiting_list |
data.frame. A df of referral dates and removals |
schedule |
Date or character vector. Should be formatted as year-month-date, e.g. "2024-04-01". The dates to schedule open referrals into (i.e. dates of unbooked future capacity) |
referral_index |
The column index in the waiting_list which contains the referral dates |
removal_index |
The column index in the waiting_list which contains the removal dates |
unscheduled |
logical. If TRUE, returns a list of scheduled and unscheduled procedures If FALSE, only returns the updated waiting list |
The updated waiting list with removal dates assigned based on
the given schedule, either as a single data.frame (default) or as
part of a list (if unscheduled = TRUE).
If unscheduled = TRUE, returns a list with two data frames:
A data.frame. The updated waiting list with scheduled removals.
A data.frame showing which slots were used, with columns:
Date. The available dates from the input
schedule.
Numeric. 1 if the slot was used to schedule a
patient, 0 if not.
referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) schedule <- c.Date("2024-01-03", "2024-01-05", "2024-01-18") updated_waiting_list <- wl_schedule(waiting_list, schedule)referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) schedule <- c.Date("2024-01-03", "2024-01-05", "2024-01-18") updated_waiting_list <- wl_schedule(waiting_list, schedule)
Creates a simulated waiting list comprising referral dates, and removal dates
wl_simulator( start_date = NULL, end_date = NULL, demand = 10, capacity = 11, waiting_list = NULL, withdrawal_prob = NA_real_, detailed_sim = FALSE )wl_simulator( start_date = NULL, end_date = NULL, demand = 10, capacity = 11, waiting_list = NULL, withdrawal_prob = NA_real_, detailed_sim = FALSE )
start_date |
Date or character (in format 'YYYY-MM-DD'); The start date to calculate from |
end_date |
Date or character (in format 'YYYY-MM-DD'); The end date to calculate to |
demand |
numeric. Weekly demand (i.e., typical referrals per week). |
capacity |
numeric. Weekly capacity (i.e., typical removals per week). |
waiting_list |
data.frame. Waiting list where each row is a pathway/patient with date columns 'Referral' and 'Removal'. |
withdrawal_prob |
numeric. Probability of a patient withdrawing. |
detailed_sim |
logical. If TRUE, simulation provides detailed output. |
A data.frame simulating a waiting list, with columns:
Referral |
Date. The date each patient was added to the waiting list. |
Removal |
Date. The date each patient was removed from the waiting
list (may be |
If detailed_sim = TRUE, returns a more detailed
data.frame with the following additional
fields:
Withdrawal |
Date. The date the patient withdrew from the waiting list. |
Priority |
Numeric. Waiting list priority level, from 1 (most urgent) to 4 (least urgent). |
Target_wait |
Numeric. Target number of days the patient should wait at the assigned priority level (e.g., 28 days for priority 2) |
Name |
Character. Patient name in the format
|
Birth_date |
Date. Date of birth. |
NHS_number |
Integer. Patient identifier, up to 100,000,000. |
Specialty_code |
Character. One-letter code representing the specialty of the procedure. |
Specialty |
Character. Full name of the specialty associated with the procedure. |
OPCS |
Character. OPCS-4 code of the selected procedure. |
Procedure |
Character. Name of the selected procedure. |
Consultant |
Character. Consultant name in the format
|
over_capacity_simulation <- wl_simulator("2024-01-01", "2024-03-31", 100, 110) under_capacity_simulation <- wl_simulator("2024-01-01", "2024-03-31", 100, 90)over_capacity_simulation <- wl_simulator("2024-01-01", "2024-03-31", 100, 110) under_capacity_simulation <- wl_simulator("2024-01-01", "2024-03-31", 100, 90)
A summary of all the key stats associated with a waiting list
wl_stats(waiting_list, target_wait = 4, start_date = NULL, end_date = NULL)wl_stats(waiting_list, target_wait = 4, start_date = NULL, end_date = NULL)
waiting_list |
data.frame. A df of referral dates and removals |
target_wait |
numeric. The required waiting time |
start_date |
Date or character (in format 'YYYY-MM-DD'); The start date to calculate from |
end_date |
Date or character (in format 'YYYY-MM-DD'); The end date to calculate to |
A data.frame of key waiting list summary statistics based on queueing theory:
Numeric. Mean number of additions to the waiting list per week.
Numeric. Mean number of removals from the waiting list per week.
Numeric. Ratio between demand and capacity.
Logical. Whether the load is greater than or equal to 1, indicating whether the waiting list is unstable and expected to grow.
Numeric. Total demand (i.e., number of referrals) over the full time period.
Numeric. Number of patients on the waiting list at the end of the time period.
Numeric. The recommended size of the waiting list
to achieve approximately 98.2% of patients being treated within their
target wait time. This is based on Little’s Law, assuming the system
is in equilibrium, with the average waiting time set to one-quarter of
the target_wait.
Logical. Whether queue_size is more than twice
the target_queue_size. A value of TRUE indicates the queue
is at risk of missing its targets.
Numeric. Mean waiting time in weeks.
Numeric. Coefficient of variation in the time between additions to the waiting list.
Numeric. Coefficient of variation in the time between removals from the waiting list.
Numeric. The weekly treatment capacity required to maintain the waiting list at its target equilibrium, assuming the target queue size has been reached.
Numeric. The temporary weekly capacity required to
reduce the waiting list to its target_queue_size within 26 weeks,
assuming current demand remains steady. Calculated only if
queue_too_big is TRUE; otherwise returns NA.
Numeric. A measure of pressure on the system, defined as
2 × mean_wait / target_wait. Values greater than 1 suggest the
system is unlikely to meet its waiting time targets.
referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) waiting_list_stats <- wl_stats(waiting_list)referrals <- c.Date("2024-01-01", "2024-01-04", "2024-01-10", "2024-01-16") removals <- c.Date("2024-01-08", NA, NA, NA) waiting_list <- data.frame("referral" = referrals, "removal" = removals) waiting_list_stats <- wl_stats(waiting_list)