# Clear environment
rm(list=ls())
# Start timer
<- Sys.time()
start.time
# Disable scientific notation
options(scipen=999)
# Get the model and helper functions (but hide loading warnings for each package)
suppressMessages(source("model.R"))
suppressMessages(source("helpers.R"))
Reproduce Figure 5
This is run in a separate script from the other figures due to issues with RStudio crashing when all scenarios were run from a single script.
Currently depends on simmer.plot() function that doesn’t work on the imported results from the csv file, so need to allow to run model to produce this plot! Hence, you will only see results if run <- TRUE
. Ordinarily, we leave as FALSE
so that quarto site is still built quickly.
Run time: 6.165 minutes (will vary between machines)
Set up
# Set the seed and default dimensions for figures
= 200
SEED
# Set file paths to save results
= "../outputs"
folder <- file.path(folder, "fig5.png") path_fig5
Run models
<- FALSE run
if (isTRUE(run)) {
<- run_model(seed = SEED, fig5=TRUE)
baseline_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE)
exclusive_f5 <- run_model(angio_inr = 2, angio_ir=0, seed = SEED, fig5=TRUE)
twoangio_f5 }
Create figure
if (isTRUE(run)) {
# Replace resource (which has been filtered to angioINR) with scenario
$resource <- "Baseline"
baseline_f5$resource <-"Exclusive-use"
exclusive_f5$resource <- "Two angio INRs"
twoangio_f5
# Combine into single object
<- dplyr::bind_rows(baseline_f5, exclusive_f5, twoangio_f5)
fig5_df
# Create figure using simmer's plot
<- plot(fig5_df, metric="utilization") +
p xlab("Scenarios") +
ylab("Utilisation") +
scale_y_continuous(labels = scales::percent, limits=c(0, 0.4)) +
ggtitle("") +
geom_text(aes(label=round(.data$Q50*100)), vjust=-1)
p
# Save to provided path
ggsave(path_fig5, width=5, height=2.5)
}
Time elapsed
if (isTRUE(run)) {
<- Sys.time()
end.time <- round((end.time - start.time), 3)
elapsed.time
elapsed.time }