| Title: | Nice selection box of goodies for hobnobbing with NHP model results |
|---|---|
| Description: | 'Wafer' goodbye to crumbly code, and dunk a sturdy reskit function in your data cuppa instead. We've clustered the cream of our results code here - it's a cracker! |
| Authors: | Fran Barton [aut, cre] (ORCID: <https://orcid.org/0000-0002-5650-1176>), Matt Dray [ctb], Rhian Davies [ctb] |
| Maintainer: | Fran Barton <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.2.0 |
| Built: | 2026-09-25 14:40:01 UTC |
| Source: | https://github.com/The-Strategy-Unit/nhp_reskit |
change and change_pct columns to a prepared results tableAdd change and change_pct columns to a prepared results table
add_change_cols(tbl)add_change_cols(tbl)
tbl |
A tibble of appropriately prepared results |
A tibble
sex+age_group or sex+tretspef_grouped tablePrepare data from the sex+age_group or sex+tretspef_grouped table
compile_detailed_activity_data( results, measure, pod_lookup = get_detailed_pods(), tretspef_lookup = get_tretspef_lookup(), activity_type = c("ip", "op", "aae"), aggregation = c("age_group", "tretspef_grouped"), pods = NULL, sites = NULL )compile_detailed_activity_data( results, measure, pod_lookup = get_detailed_pods(), tretspef_lookup = get_tretspef_lookup(), activity_type = c("ip", "op", "aae"), aggregation = c("age_group", "tretspef_grouped"), pods = NULL, sites = NULL )
results |
A named list containing NHP results tables |
measure |
The measure to focus on for the output table. Valid values depend on which activity_type is selected |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
tretspef_lookup |
A tibble, or a function that returns a tibble,
containing a |
activity_type |
string. One of "ip", "op", "aae". "ip" is the default. |
aggregation |
string. One of "age_group" or "tretspef_grouped" |
pods |
character vector. PoD labels to filter data to. The default
value of |
sites |
Either |
Compile data to support the "activity distribution summary" tables
compile_distribution_plot_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, pod_lookup = get_detailed_pods(), sites = NULL )compile_distribution_plot_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, pod_lookup = get_detailed_pods(), sites = NULL )
results |
A named list containing NHP results tables |
measure |
The measure to focus on for the output table. Valid values depend on which activity_type is selected |
activity_type |
string. One of "ip", "op", "aae". "ip" is the default. |
pods |
character vector. PoD labels to filter data to. The default
value of |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A tibble
Compile data to support the "activity distribution summary" tables
compile_distribution_summary_data( results, value_type = c("median", "principal"), pod_lookup = get_detailed_pods(), sites = NULL )compile_distribution_summary_data( results, value_type = c("median", "principal"), pod_lookup = get_detailed_pods(), sites = NULL )
results |
A named list containing NHP results tables |
value_type |
string Either "median" or "principal" |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A tibble
step_counts table to use for waterfall chartPrepare data from the step_counts table to use for waterfall chart
compile_grouped_impact_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_detailed_pods(), tpma_lookup = get_tpma_label_lookup(), include_baseline = TRUE )compile_grouped_impact_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_detailed_pods(), tpma_lookup = get_tpma_label_lookup(), include_baseline = TRUE )
results |
A named list containing NHP results tables |
measure |
The measure to focus on for the output table. Valid values depend on which activity_type is selected |
activity_type |
string. One of "ip", "op", "aae". "ip" is the default. |
pods |
character vector. PoD labels to filter data to. The default
value of |
sites |
Either |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
tpma_lookup |
A tibble, or a function that returns a tibble, containing
a column named |
include_baseline |
Boolean. Whether to include baseline data |
A prepared tibble of step count changes for each included TPMA
Prepare data from tretspef+los_group results for displaying as summary table
compile_principal_los_data( results, measure, pod_lookup = get_principal_pods(), sites = NULL )compile_principal_los_data( results, measure, pod_lookup = get_principal_pods(), sites = NULL )
results |
A named list containing NHP results tables |
measure |
Either "admissions" or "beddays". The measure to focus on for the output table |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A filtered and sorted tibble of principal projections of results, by point of delivery and grouped length of stay
Prepare data from default results table for displaying as summary table
compile_principal_pod_data( results, pod_lookup = get_principal_pods(), sites = NULL )compile_principal_pod_data( results, pod_lookup = get_principal_pods(), sites = NULL )
results |
A named list containing NHP results tables |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A filtered and sorted tibble of principal projections of results, by activity type and point of delivery (PoD)
step_counts table to use for TPMA impact chartPrepare data from step_counts table to use for TPMA impact chart
compile_tpma_impact_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_detailed_pods(), tpma_lookup = get_tpma_label_lookup(), sort_by = c("value", "tpma_label") )compile_tpma_impact_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_detailed_pods(), tpma_lookup = get_tpma_label_lookup(), sort_by = c("value", "tpma_label") )
results |
A named list containing NHP results tables |
measure |
The measure to focus on for the output table. Valid values depend on which activity_type is selected |
activity_type |
string. One of "ip", "op", "aae". "ip" is the default. |
pods |
character vector. PoD labels to filter data to. The default
value of |
sites |
Either |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
tpma_lookup |
A tibble, or a function that returns a tibble, containing
a column named |
sort_by |
string, one of "value" or "tpma_label". The former sorts the output table by the value of the change, the latter alphabetically by the TPMA label |
A prepared tibble of projected negative changes in activity, by TPMA
Intended to be used to create a table to be exported to .csv/.xlsx
export_detailed_activity_data( results, pod_lookup = get_detailed_pods(), tretspef_lookup = get_tretspef_lookup(), aggregation = c("age_group", "tretspef_grouped"), sites = NULL )export_detailed_activity_data( results, pod_lookup = get_detailed_pods(), tretspef_lookup = get_tretspef_lookup(), aggregation = c("age_group", "tretspef_grouped"), sites = NULL )
results |
A named list containing NHP results tables |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
tretspef_lookup |
A tibble, or a function that returns a tibble,
containing a |
aggregation |
string. One of "age_group" or "tretspef_grouped" |
sites |
Either |
A tibble
Intended to be used to create a table to be exported to .csv/.xlsx
export_distribution_summary_data( results, pod_lookup = get_detailed_pods(), sites = NULL )export_distribution_summary_data( results, pod_lookup = get_detailed_pods(), sites = NULL )
results |
A named list containing NHP results tables |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A tibble
Intended to be used to create a table to be exported to .csv/.xlsx
export_impact_data( results, sites = NULL, pod_lookup = get_detailed_pods(), tpma_lookup = get_tpma_label_lookup() )export_impact_data( results, sites = NULL, pod_lookup = get_detailed_pods(), tpma_lookup = get_tpma_label_lookup() )
results |
A named list containing NHP results tables |
sites |
Either |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
tpma_lookup |
A tibble, or a function that returns a tibble, containing
a column named |
A tibble
Intended to be used to create a table to be exported to .csv/.xlsx
export_principal_los_data( results, pod_lookup = get_principal_pods(), sites = NULL )export_principal_los_data( results, pod_lookup = get_principal_pods(), sites = NULL )
results |
A named list containing NHP results tables |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A tibble
Intended to be used to create a table to be exported to .csv/.xlsx
export_principal_pod_data( results, pod_lookup = get_principal_pods(), sites = NULL )export_principal_pod_data( results, pod_lookup = get_principal_pods(), sites = NULL )
results |
A named list containing NHP results tables |
pod_lookup |
A tibble, or a function that returns a tibble, containing
columns named |
sites |
Either |
A tibble
This function condenses all A&E activity to a single category - compare get_detailed_pods which keeps all A&E categories
get_detailed_pods() get_principal_pods()get_detailed_pods() get_principal_pods()
A tibble
A tibble
Prepare a lookup table for all current TPMAs
get_tpma_label_lookup()get_tpma_label_lookup()
A 4-column tibble, with columns strategy, activity_type,
change_factor and tpma_label
Get a lookup of tretspef codes to descriptions
get_tretspef_lookup()get_tretspef_lookup()
A 2-column tibble with columns code and tretspef
Generate a "beeswarm" chart showing the distribution of model run values
make_beeswarm_distrib_plot(distrib_plot_data, show_zero = FALSE)make_beeswarm_distrib_plot(distrib_plot_data, show_zero = FALSE)
distrib_plot_data |
data frame. As produced by compile_distribution_plot_data |
show_zero |
Boolean. Whether to extend the chart to show a zero value, for context. |
Generate a cumulative distribution function (ecdf) chart of model run values
make_cumulative_distrib_plot(distrib_plot_data, show_zero = FALSE)make_cumulative_distrib_plot(distrib_plot_data, show_zero = FALSE)
distrib_plot_data |
data frame. As produced by compile_distribution_plot_data |
show_zero |
Boolean. Whether to extend the chart to show a zero value, for context. |
Create a gt table with data from compile_detailed_activity_data
make_detailed_activity_table(detailed_activity_data, final_year)make_detailed_activity_table(detailed_activity_data, final_year)
detailed_activity_data |
A suitable tibble |
final_year |
string. The horizon year eg "2042/43" |
A gt table
Create a gt table with data from compile_distribution_summary_data
make_distribution_summary_table(distr_summary_data)make_distribution_summary_table(distr_summary_data)
distr_summary_data |
A suitable tibble |
A gt table
Generate overall change factor ("waterfall") chart
make_grouped_impact_plot(grouped_impact_data)make_grouped_impact_plot(grouped_impact_data)
grouped_impact_data |
tibble, as produced by compile_grouped_impact_data |
Create a gt table with data from compile_principal_los_data
make_principal_los_table(principal_los_data)make_principal_los_table(principal_los_data)
principal_los_data |
A suitable tibble |
A gt table
Create a gt table with data from compile_principal_pod_data
make_principal_pod_table(principal_pod_data)make_principal_pod_table(principal_pod_data)
principal_pod_data |
A suitable tibble |
A gt table
Generate bar charts by change factor at individual TPMA level
make_tpma_impact_plot(tpma_impact_data)make_tpma_impact_plot(tpma_impact_data)
tpma_impact_data |
tibble, as produced by compile_tpma_impact_data |
Read a selection of (or all) parquet files in an Azure directory
read_results_parquet_files(container, path, tables = NULL)read_results_parquet_files(container, path, tables = NULL)
container |
An Azure container. |
path |
string. Path to an Azure directory of model results data. Potentially pulled from a field in a table of model runs metadata |
tables |
character vector. |
A named list of tibbles
## Not run: data <- azkit::get_container("data_container") |> read_results_parquet_files("data/dev/national/test", "acuity") data_list <- azkit::get_container("data_container") |> read_results_parquet_files(path = "files/v4.0/national") ## End(Not run)## Not run: data <- azkit::get_container("data_container") |> read_results_parquet_files("data/dev/national/test", "acuity") data_list <- azkit::get_container("data_container") |> read_results_parquet_files(path = "files/v4.0/national") ## End(Not run)
Wrangle tables from old-style results to match format of new-style results
shim_results(results)shim_results(results)
results |
List of old style NHP results tables |
List of NHP results tables in the "new" format