R6 class storing health statistics for a list of hospital health units.
hospital_grp.Rd
R6 class storing health statistics for a list of hospital health units.
R6 class storing health statistics for a list of hospital health units.
Details
This R6 class is designed to store bed occupancy statistics for multiple hospitals. This class can be used to plot summary statistics and create shiny UI/server objects.
Super class
HealthDataScotland::health_unitgrp
-> hospital_grp
Methods
Inherited methods
HealthDataScotland::health_unitgrp$ID()
HealthDataScotland::health_unitgrp$IDs()
HealthDataScotland::health_unitgrp$combine_data()
HealthDataScotland::health_unitgrp$data()
HealthDataScotland::health_unitgrp$download_handler()
HealthDataScotland::health_unitgrp$get_download()
HealthDataScotland::health_unitgrp$health_unit()
HealthDataScotland::health_unitgrp$initialize()
HealthDataScotland::health_unitgrp$metadata()
HealthDataScotland::health_unitgrp$sf()
HealthDataScotland::health_unitgrp$subset()
HealthDataScotland::health_unitgrp$titles()
HealthDataScotland::health_unitgrp$validate()
Method plot()
Plot hospital grp.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for options....
Passed to plot functions.
Examples
x <- example_hospital_grp_unit()
x[["plot"]](type = "hospital_bar")
Method plot_data()
Generate plot data for hospital grp.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for options....
Passed to plot data functions.
Examples
x <- example_hospital_grp_unit()
x[["plot_data"]](type = "hospital_bar")
Method plot_info()
Get plot info for hospital grp.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for options....
Passed to plot info functions.
Examples
x <- example_hospital_grp_unit()
x[["plot_info"]](type = "hospital_bar")
Examples
gps <- lapply(c("A101H", "A201H"), example_hospital_unit)
sf <- get_sf("hospital")[get_sf("hospital")[["ID"]] %in% c("A101H", "A201H"), ]
x <- hospital_grp[["new"]](gps, sf, .id = "gp")
x[["ID"]]()
#> [1] "gp"
x[["IDs"]]()
#> [1] "A101H" "A201H"
x[["titles"]]()
#> [1] "Arran War Memorial Hospital" "Ailsa Hospital"
x[["metadata"]]()
#> # A tibble: 2 × 16
#> datasetID ID HospitalName AddressLine1 AddressLine2 AddressLine2QF
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 c698f450-eeed-41a… A101H Arran War M… Lamlash Isle of Arr… NA
#> 2 c698f450-eeed-41a… A201H Ailsa Hospi… Dalmellingt… Ayr NA
#> # ℹ 10 more variables: AddressLine3 <chr>, AddressLine3QF <chr>,
#> # AddressLine4 <chr>, AddressLine4QF <chr>, Postcode <chr>, HBName <chr>,
#> # HSCP <chr>, CouncilArea <chr>, IntermediateZone <chr>, DataZone <chr>
x[["data"]]()
#> [[1]]
#> <hospital>
#> Inherits from: <health_unit>
#> Public:
#> .data: tbl_df, tbl, data.frame
#> .metadata: tbl_df, tbl, data.frame
#> ID: function ()
#> address: function ()
#> available_plots: function ()
#> clone: function (deep = FALSE)
#> combine_data: function ()
#> data: function ()
#> health_board: function ()
#> initialize: function (.metadata, .data)
#> metadata: function ()
#> plot: function (type, ...)
#> plot_data: function (type, ...)
#> plot_info: function (type, ...)
#> popup_modal: function (ns)
#> server: function ()
#> title: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> annual_cols: function ()
#> daily_cols: function ()
#> required_data_cols: function ()
#> required_metadata_cols: function ()
#> specialty_choices: function ()
#> specialty_line: function (...)
#> specialty_line_data: function (data_type = c("annual", "daily"), specialties = "All Specialties")
#> specialty_line_info: function (data_type = c("annual", "daily"))
#> title_col: function ()
#>
#> [[2]]
#> <hospital>
#> Inherits from: <health_unit>
#> Public:
#> .data: tbl_df, tbl, data.frame
#> .metadata: tbl_df, tbl, data.frame
#> ID: function ()
#> address: function ()
#> available_plots: function ()
#> clone: function (deep = FALSE)
#> combine_data: function ()
#> data: function ()
#> health_board: function ()
#> initialize: function (.metadata, .data)
#> metadata: function ()
#> plot: function (type, ...)
#> plot_data: function (type, ...)
#> plot_info: function (type, ...)
#> popup_modal: function (ns)
#> server: function ()
#> title: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> annual_cols: function ()
#> daily_cols: function ()
#> required_data_cols: function ()
#> required_metadata_cols: function ()
#> specialty_choices: function ()
#> specialty_line: function (...)
#> specialty_line_data: function (data_type = c("annual", "daily"), specialties = "All Specialties")
#> specialty_line_info: function (data_type = c("annual", "daily"))
#> title_col: function ()
#>
x[["subset"]](id = "A201H")
#> <hospital_grp>
#> Inherits from: <health_unitgrp>
#> Public:
#> .data: list
#> .id: gp
#> .sf: sf, tbl_df, tbl, data.frame
#> ID: function ()
#> IDs: function ()
#> available_plots: function ()
#> clone: function (deep = FALSE)
#> combine_data: function ()
#> data: function ()
#> download_handler: function ()
#> get_download: function ()
#> health_unit: function (id)
#> initialize: function (.data, .sf, .id)
#> metadata: function ()
#> plot: function (type, ...)
#> plot_data: function (type, ...)
#> plot_info: function (type, ...)
#> server: function ()
#> sf: function ()
#> subset: function (id)
#> titles: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> bar_data: function (x, ...)
#> bar_echart: function (x, group = "HBName", x_axis = "", y_axis = "PercentageOccupancy")
#> health_board_bar: function (...)
#> health_board_bar_data: function (specialties = "All Specialties", health_boards = private[["health_board_choices"]]())
#> health_board_bar_info: function ()
#> health_board_choices: function ()
#> health_board_data: function (specialties, health_boards)
#> health_board_trend: function (...)
#> health_board_trend_data: function (specialties = "All Specialties", health_boards = private[["health_board_choices"]]())
#> health_board_trend_info: function ()
#> hospital_bar: function (...)
#> hospital_bar_data: function (specialties = private[["specialty_choices"]](), hospitals = private[["unit_choices"]]())
#> hospital_bar_info: function ()
#> hospital_data: function (specialties, hospitals)
#> hospital_trend: function (...)
#> hospital_trend_data: function (specialties = "All Specialties", hospitals = private[["unit_choices"]]())
#> hospital_trend_info: function ()
#> id_name_labels: function (x, name)
#> id_name_selection: function ()
#> map_combine: function (func, nms = self[["IDs"]](), id = "ID", ...)
#> national_trend: function (...)
#> national_trend_data: function (specialties = "All Specialties")
#> national_trend_info: function ()
#> req_plot_cols: function ()
#> specialty_choices: function ()
#> summarise_percentage_occupancy: function (x, groups = colnames(x))
#> trend_data: function (x, ...)
#> trend_echart: function (x)
#> unit_choices: function ()
x[["plot"]](type = "hospital_bar")
x[["plot_data"]](type = "hospital_bar")
#> # A tibble: 4 × 8
#> # Groups: FinancialYear [2]
#> FinancialYear ID HBName `All Specialties` `Community Grouping`
#> <chr> <chr> <chr> <dbl> <dbl>
#> 1 2022/23 A101H - Arran War… S0800… 77.4 77.4
#> 2 2022/23 A201H - Ailsa Hos… S0800… 77.9 NA
#> 3 2023/24 A101H - Arran War… S0800… 68.5 68.5
#> 4 2023/24 A201H - Ailsa Hos… S0800… 72.6 NA
#> # ℹ 3 more variables: `GP Other than Obstetrics` <dbl>,
#> # `Mental Health Grouping` <dbl>, `Psychiatry of Old Age` <dbl>
x[["plot_info"]](type = "hospital_bar")
#> [1] "This bar chart shows the average hospital bed occupancy (y-axis)\n per hospital (x-axis) for each specialty (colour). Seetings can be\n used to show data for different specialties (default is all\n specialties) and hospitals."
if (FALSE) { # \dontrun{
x[["ui"]]()
x[["server"]]()
} # }
## ------------------------------------------------
## Method `hospital_grp$plot`
## ------------------------------------------------
x <- example_hospital_grp_unit()
x[["plot"]](type = "hospital_bar")
## ------------------------------------------------
## Method `hospital_grp$plot_data`
## ------------------------------------------------
x <- example_hospital_grp_unit()
x[["plot_data"]](type = "hospital_bar")
#> # A tibble: 4 × 8
#> # Groups: FinancialYear [2]
#> FinancialYear ID HBName `All Specialties` `Community Grouping`
#> <chr> <chr> <chr> <dbl> <dbl>
#> 1 2022/23 A101H - Arran War… S0800… 77.4 77.4
#> 2 2022/23 A201H - Ailsa Hos… S0800… 77.9 NA
#> 3 2023/24 A101H - Arran War… S0800… 68.5 68.5
#> 4 2023/24 A201H - Ailsa Hos… S0800… 72.6 NA
#> # ℹ 3 more variables: `GP Other than Obstetrics` <dbl>,
#> # `Mental Health Grouping` <dbl>, `Psychiatry of Old Age` <dbl>
## ------------------------------------------------
## Method `hospital_grp$plot_info`
## ------------------------------------------------
x <- example_hospital_grp_unit()
x[["plot_info"]](type = "hospital_bar")
#> [1] "This bar chart shows the average hospital bed occupancy (y-axis)\n per hospital (x-axis) for each specialty (colour). Seetings can be\n used to show data for different specialties (default is all\n specialties) and hospitals."