R6 class storing health statistics for a list of gp health units.
R6 class storing health statistics for a list of gp health units.
Details
This R6 class is designed to store population demography data for multiple GP practices. This class can be used to plot summary statistics and create shiny UI/server objects.
Super class
HealthDataScotland::health_unitgrp -> gp_grp
Methods
Inherited methods
HealthDataScotland::health_unitgrp$ID()HealthDataScotland::health_unitgrp$IDs()HealthDataScotland::health_unitgrp$addresses()HealthDataScotland::health_unitgrp$combine_data()HealthDataScotland::health_unitgrp$data()HealthDataScotland::health_unitgrp$datatable()HealthDataScotland::health_unitgrp$download_handler()HealthDataScotland::health_unitgrp$health_boards()HealthDataScotland::health_unitgrp$health_unit()HealthDataScotland::health_unitgrp$initialize()HealthDataScotland::health_unitgrp$metadata()HealthDataScotland::health_unitgrp$subset()HealthDataScotland::health_unitgrp$summary()HealthDataScotland::health_unitgrp$summary_info()HealthDataScotland::health_unitgrp$summary_types()HealthDataScotland::health_unitgrp$titles()HealthDataScotland::health_unitgrp$validate()
Method plot()
Plot gp grp.
Arguments
type(character(1))
Character specifying plot type. Seeplot_typesfor options....Passed to plot functions.
Examples
x <- example_gp_grp_unit()
x[["plot"]](type = "gp_bar")Method plot_data()
Get plot data for gp grp.
Arguments
type(character(1))
Character specifying plot type. Seeplot_typesfor options....Passed to plot data functions.
Examples
x <- example_gp_grp_unit()
x[["plot_data"]](type = "gp_bar")Method plot_info()
Get plot info for gp grp.
Arguments
type(character(1))
Character specifying plot type. Seeplot_typesfor options....Passed to plot info functions.
Examples
x <- example_gp_grp_unit()
x[["plot_info"]](type = "gp_bar")Examples
gps <- lapply(c("10002", "10017"), example_gp_unit)
x <- gp_grp[["new"]](gps, .id = "gp")
x[["ID"]]()
#> [1] "gp"
x[["IDs"]]()
#> [1] "10002" "10017"
x[["titles"]]()
#> [1] "Muirhead Medical Centre" "The Blue Practice"
x[["metadata"]]()
#> # A tibble: 2 × 16
#> datasetID ID GPPracticeName PracticeListSize AddressLine1 AddressLine2
#> <chr> <chr> <chr> <dbl> <chr> <chr>
#> 1 b3b126d3-3b0c… 10002 Muirhead Medi… 8251 Muirhead Me… Liff Road
#> 2 b3b126d3-3b0c… 10017 The Blue Prac… 7272 The Blue Pr… Crieff Medi…
#> # ℹ 10 more variables: AddressLine3 <chr>, AddressLine4 <chr>, Postcode <chr>,
#> # TelephoneNumber <chr>, PracticeType <chr>, Dispensing <lgl>, HBName <chr>,
#> # HSCP <chr>, DataZone <chr>, GPCluster <chr>
x[["data"]]()
#> [[1]]
#> <gp>
#> Inherits from: <health_unit>
#> Public:
#> .data: tbl_df, tbl, data.frame
#> .metadata: tbl_df, tbl, data.frame
#> ID: function ()
#> address: function ()
#> clone: function (deep = FALSE)
#> combine_data: function ()
#> data: function ()
#> datatable: function (type, ...)
#> health_board: function ()
#> initialize: function (.metadata, .data)
#> metadata: function ()
#> plot: function (type, ...)
#> plot_data: function (type, ...)
#> plot_info: function (type, ...)
#> plot_types: function ()
#> popup_modal: function (ns)
#> server: function ()
#> summary: function (type, ...)
#> summary_info: function (type, ...)
#> summary_types: function ()
#> telephone: function ()
#> title: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> population_pyramid: function (...)
#> population_pyramid_data: function ()
#> population_pyramid_info: function ()
#> population_summary: function (...)
#> population_summary_info: function ()
#> population_trend: function (...)
#> population_trend_data: function ()
#> population_trend_info: function ()
#> population_trend_y_range: function ()
#> required_data_cols: function ()
#> required_metadata_cols: function ()
#> title_col: function ()
#>
#> [[2]]
#> <gp>
#> Inherits from: <health_unit>
#> Public:
#> .data: tbl_df, tbl, data.frame
#> .metadata: tbl_df, tbl, data.frame
#> ID: function ()
#> address: function ()
#> clone: function (deep = FALSE)
#> combine_data: function ()
#> data: function ()
#> datatable: function (type, ...)
#> health_board: function ()
#> initialize: function (.metadata, .data)
#> metadata: function ()
#> plot: function (type, ...)
#> plot_data: function (type, ...)
#> plot_info: function (type, ...)
#> plot_types: function ()
#> popup_modal: function (ns)
#> server: function ()
#> summary: function (type, ...)
#> summary_info: function (type, ...)
#> summary_types: function ()
#> telephone: function ()
#> title: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> population_pyramid: function (...)
#> population_pyramid_data: function ()
#> population_pyramid_info: function ()
#> population_summary: function (...)
#> population_summary_info: function ()
#> population_trend: function (...)
#> population_trend_data: function ()
#> population_trend_info: function ()
#> population_trend_y_range: function ()
#> required_data_cols: function ()
#> required_metadata_cols: function ()
#> title_col: function ()
#>
x[["subset"]](id = "10002")
#> <gp_grp>
#> Inherits from: <health_unitgrp>
#> Public:
#> .data: list
#> .id: gp
#> ID: function ()
#> IDs: function ()
#> addresses: function ()
#> clone: function (deep = FALSE)
#> combine_data: function ()
#> data: function ()
#> datatable: function (type, ns = NULL, ...)
#> download_handler: function ()
#> health_boards: function ()
#> health_unit: function (id)
#> initialize: function (.data, .id)
#> metadata: function ()
#> plot: function (type, ...)
#> plot_data: function (type, ...)
#> plot_info: function (type, ...)
#> plot_types: function ()
#> server: function ()
#> subset: function (id)
#> summary: function (type, ...)
#> summary_info: function (type, ...)
#> summary_types: function ()
#> telephones: function ()
#> titles: function ()
#> ui: function (...)
#> validate: function ()
#> Private:
#> bar_data: function (x, col, ...)
#> bar_echart: function (x)
#> dt_btn: function (ns)
#> gender_choices: function ()
#> gp_bar: function (...)
#> gp_bar_data: function (gp = private[["unit_choices"]](), gender = private[["gender_choices"]]())
#> gp_bar_info: function ()
#> gp_data: function (gp, gender)
#> gp_trend: function (...)
#> gp_trend_data: function (gp = private[["unit_choices"]](), gender = private[["gender_choices"]]())
#> gp_trend_info: function ()
#> health_board_bar: function (...)
#> health_board_bar_data: function (health_board = private[["health_board_choices"]](),
#> health_board_bar_info: function ()
#> health_board_choices: function ()
#> health_board_data: function (health_board, gender)
#> health_board_trend: function (...)
#> health_board_trend_data: function (health_board = private[["health_board_choices"]](),
#> health_board_trend_info: function ()
#> id_name_labels: function (x, name)
#> id_name_selection: function ()
#> lookup: function (...)
#> lookup_info: function (...)
#> map_combine: function (func, nms = self[["IDs"]](), id = "ID", ...)
#> national_pyramid: function ()
#> national_pyramid_data: function ()
#> national_pyramid_info: function ()
#> national_trend: function (...)
#> national_trend_data: function ()
#> national_trend_info: function ()
#> trend_data: function (x, ...)
#> trend_echart: function (x)
#> unit_choices: function ()
x[["plot"]](type = "national_pyramid")
x[["plot_data"]](type = "national_pyramid")
#> # A tibble: 24 × 4
#> # Groups: Date [3]
#> Date Age Female Male
#> <dbl> <fct> <dbl> <dbl>
#> 1 20231001 Ages0to4 -283 314
#> 2 20231001 Ages5to14 -752 825
#> 3 20231001 Ages15to24 -860 928
#> 4 20231001 Ages25to44 -1710 1690
#> 5 20231001 Ages45to64 -2199 2146
#> 6 20231001 Ages65to74 -981 916
#> 7 20231001 Ages75to84 -675 605
#> 8 20231001 Ages85plus -262 201
#> 9 20240101 Ages0to4 -284 316
#> 10 20240101 Ages5to14 -753 841
#> # ℹ 14 more rows
x[["plot_info"]](type = "national_pyramid")
#> [1] "This bar chart shows a population pyramid of the total number of\n GP registered patients in Scotland (x-axis) across age category\n (y-axis) for each gender (colour). Specifically, this plot combines data for all available GP practices\n across Scotland and calculates the total number of GP registered\n patients per age and gender. Please note this may show a total number of patients\n greater than the population. This may be caused by a few factors such as\n patients being registered at multiple GP practices. Please consult the\n original data sets for further information."
x[["summary"]](type = "lookup")
#> Title ID
#> 1 Muirhead Medical Centre 10002
#> 2 The Blue Practice 10017
#> Address
#> 1 Muirhead Medical Centre, Liff Road, Muirhead, DD2 5NH
#> 2 The Blue Practice, Crieff Medical Centre, King Street, Crieff, PH7 3SA
#> Telephone Health board
#> 1 01382 580 264 S08000030
#> 2 01764 652 283 S08000030
x[["summary_info"]](type = "lookup")
#> [1] "This lookup table presents data for all available GP practices\n in the data set. This table can be searched, filtered and\n the 'Plot' column allows the user to view statistics for a\n selected GP practice."
if (FALSE) { # \dontrun{
x[["ui"]]()
x[["server"]]()
} # }
## ------------------------------------------------
## Method `gp_grp$plot`
## ------------------------------------------------
x <- example_gp_grp_unit()
x[["plot"]](type = "gp_bar")
## ------------------------------------------------
## Method `gp_grp$plot_data`
## ------------------------------------------------
x <- example_gp_grp_unit()
x[["plot_data"]](type = "gp_bar")
#> # A tibble: 24 × 4
#> # Groups: Date [3]
#> Date Age `10002 - Muirhead Medical Centre` 10017 - The Blue Prac…¹
#> <dbl> <fct> <dbl> <dbl>
#> 1 20231001 Ages0to4 186 128
#> 2 20231001 Ages5to14 463 362
#> 3 20231001 Ages15to24 419 509
#> 4 20231001 Ages25to44 952 738
#> 5 20231001 Ages45to64 1170 976
#> 6 20231001 Ages65to74 494 422
#> 7 20231001 Ages75to84 307 298
#> 8 20231001 Ages85plus 94 107
#> 9 20240101 Ages0to4 190 126
#> 10 20240101 Ages5to14 456 385
#> # ℹ 14 more rows
#> # ℹ abbreviated name: ¹`10017 - The Blue Practice`
## ------------------------------------------------
## Method `gp_grp$plot_info`
## ------------------------------------------------
x <- example_gp_grp_unit()
x[["plot_info"]](type = "gp_bar")
#> [1] "This bar chart shows the total number of GP registered patients\n (y-axis) for each individal GP practice (colour) across\n age categories (x-axis). Settings can be used to show data for\n different GP practices and genders."