| 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.0.0 |
| Built: | 2026-05-20 20:37:41 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
step_counts results table for display as chartsPrepare data from the step_counts results table for display as charts
compile_change_factor_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_principal_pods(), tpma_lookup = get_tpma_label_lookup(), include_baseline = TRUE )compile_change_factor_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_principal_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
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 results table for display as chartsPrepare data from step_counts results table for display as charts
compile_indiv_change_factor_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_principal_pods(), tpma_lookup = get_tpma_label_lookup(), sort_by = c("value", "tpma_label") )compile_indiv_change_factor_data( results, measure, activity_type = c("ip", "op", "aae"), pods = NULL, sites = NULL, pod_lookup = get_principal_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
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)
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_principal_cf_data( results, sites = NULL, pod_lookup = get_principal_pods(), tpma_lookup = get_tpma_label_lookup() )export_principal_cf_data( results, sites = NULL, pod_lookup = get_principal_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(use_local = FALSE) get_principal_pods(use_local = FALSE)get_detailed_pods(use_local = FALSE) get_principal_pods(use_local = FALSE)
use_local |
logical. Whether to use a local file (internal to the
reskit package) or attempt to pull the lookup file from GitHub. Default is
|
A tibble
A tibble
Provides some logic and checks to assist the user in locating a valid directory from which to read in NHP results data
get_results_dir_path( container, path, version, scheme, scenario = NULL, dttm_stamp = NULL )get_results_dir_path( container, path, version, scheme, scenario = NULL, dttm_stamp = NULL )
container |
An Azure container. |
path |
string. The path to the directory within the container, where the desired results data is stored |
version |
string. The NHP model version in the format "v3.6", or "dev" |
scheme |
string. The code/name of the NHP scheme. May be "national" etc |
scenario |
string. If |
dttm_stamp |
string. If |
A path to an Azure blob storage directory, as a string
Currently reads from a fixed location within the package.
get_tpma_label_lookup()get_tpma_label_lookup()
A 2-column tibble, with columns strategy and tpma_label
Currently reads from a fixed location within the package.
get_tretspef_lookup()get_tretspef_lookup()
A 2-column tibble with columns code and tretspef
The "default" table is recommended
get_trust_sites(res_tbl, col = "sitetret")get_trust_sites(res_tbl, col = "sitetret")
res_tbl |
A tibble from the results list |
col |
string The name of the column containing site codes. |
A character vector
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 bar charts by change factor at individual TPMA level
make_individual_cf_plot(indiv_change_factor_data)make_individual_cf_plot(indiv_change_factor_data)
indiv_change_factor_data |
data frame. As produced by compile_indiv_change_factor_data |
Generate overall change factor ("waterfall") chart
make_overall_cf_plot(principal_change_factor_data)make_overall_cf_plot(principal_change_factor_data)
principal_change_factor_data |
data frame. As produced by compile_change_factor_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
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 results data. Potentially produced by get_results_dir_path |
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") |> get_results_dir_path("files", version = "v4.0", scheme = "national") |> read_results_parquet_files() ## 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") |> get_results_dir_path("files", version = "v4.0", scheme = "national") |> read_results_parquet_files() ## 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