R6 class storing health statistics for a list of gp health units.
gp_grp.Rd
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$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 gp grp.
Arguments
type
(character(1))
Character specifying plot type. Seeavailable_plots
for 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. Seeavailable_plots
for 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. Seeavailable_plots
for 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)
sf <- get_sf()[get_sf()[["ID"]] %in% c("10002", "100017"), ]
x <- gp_grp[["new"]](gps, sf, .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 ()
#> 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 ()
#> telephone: function ()
#> title: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> population_pyramid: function (...)
#> population_pyramid_data: function ()
#> population_pyramid_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 ()
#> 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 ()
#> telephone: function ()
#> title: function ()
#> ui: function (ns)
#> validate: function ()
#> Private:
#> population_pyramid: function (...)
#> population_pyramid_data: function ()
#> population_pyramid_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
#> .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 ()
#> validate: function ()
#> Private:
#> bar_data: function (x, col, ...)
#> bar_echart: function (x)
#> 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 ()
#> 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."
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."