Skip to contents

R6 class for creating interactive map of health units.

R6 class for creating interactive map of health units.

Details

This R6 class is designed to store sf spatial data for GP practices, hospitals and health boards. This class is used to create a map with interactive pins of health centres.

Public fields

.sf

A sf spatial data.frame storing spatial data for health units.

.id

Character ID of object.

.title

Character title of object.

Methods


Method new()

Create instance of map.

Usage

map$new(.sf, .id = "map", .title = "Interactive Map")

Arguments

.sf

(sf)
A sf spatial data.frame storing spatial data for health units.

.id

(character(1))
Character id of object. Default is "map".

.title

(character(1))
Character title of object. Default is "Interactive Map".


Method validate()

Validate structure of map object.

Usage

map$validate()


Method sf()

Get sf spatial data.frame of map object.

Usage

map$sf()


Method id()

Get id of map object.

Usage

map$id()


Method title()

Get title of map object.

Usage

map$title()


Method available_plots()

Get character vector of available plots for map object.

Usage

map$available_plots()


Method plot()

Plot map object.

Usage

map$plot(type, ...)

Arguments

type

(character(1))
Character specifying plot type. See available_plots for options.

...

Passed to plot functions.

Examples

x <- example_map_object()
x[["plot"]](type = "interactive_map")


Method plot_data()

Generate plot data for map object.

Usage

map$plot_data(type, ...)

Arguments

type

(character(1))
Character specifying plot type. See available_plots for options.

...

Passed to plot data functions.

Examples

x <- example_map_object()
x[["plot_data"]](type = "interactive_map")


Method plot_info()

Get plot infot for map object.

Usage

map$plot_info(type, ...)

Arguments

type

(character(1))
Character specifying plot type. See available_plots for options.

...

Passed to plot data functions.

Examples

x <- example_map_object()
x[["plot_info"]](type = "interactive_map")


Method ui()

Create ui for map object.

Usage

map$ui()


Method server()

Create server for map object.

Usage

map$server(data)

Arguments

data

(list)
List of with gp_grp and hospital_grp objects to use for interactive map pop-up modals.


Method clone()

The objects of this class are cloneable with this method.

Usage

map$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

x <- example_map_object()
x[["id"]]()
#> [1] "map"
x[["title"]]()
#> [1] "Interactive Map"
x[["sf"]]()
#> Simple feature collection with 18 features and 2 fields
#> Geometry type: GEOMETRY
#> Dimension:     XY
#> Bounding box:  xmin: -8.650007 ymin: 54.63321 xmax: -0.7251864 ymax: 60.86076
#> CRS:           NA
#> # A tibble: 18 × 3
#>    ID        type                                                       geometry
#>  * <chr>     <chr>                                                    <GEOMETRY>
#>  1 10002     gp                                       POINT (-3.065759 56.49556)
#>  2 10017     gp                                        POINT (-3.84469 56.37021)
#>  3 A101H     hospital                                 POINT (-5.115637 55.54328)
#>  4 A201H     hospital                                 POINT (-4.593139 55.43402)
#>  5 S08000015 board    MULTIPOLYGON (((-5.118354 55.25852, -5.106465 55.25166, -…
#>  6 S08000016 board    MULTIPOLYGON (((-2.865102 55.1352, -2.876198 55.14205, -2…
#>  7 S08000017 board    MULTIPOLYGON (((-4.084061 54.76898, -4.082476 54.76524, -…
#>  8 S08000019 board    MULTIPOLYGON (((-4.309941 56.51536, -4.29726 56.47488, -4…
#>  9 S08000020 board    MULTIPOLYGON (((-2.271474 56.83238, -2.271474 56.83175, -…
#> 10 S08000022 board    MULTIPOLYGON (((-5.572492 55.28654, -5.564566 55.28156, -…
#> 11 S08000024 board    MULTIPOLYGON (((-3.3874 56.00091, -3.388192 56.00154, -3.…
#> 12 S08000025 board    MULTIPOLYGON (((-2.908693 58.67529, -2.911071 58.67343, -…
#> 13 S08000026 board    MULTIPOLYGON (((-1.650105 59.508, -1.650898 59.50676, -1.…
#> 14 S08000028 board    MULTIPOLYGON (((-7.644247 56.79002, -7.6173 56.78816, -7.…
#> 15 S08000029 board    MULTIPOLYGON (((-3.302596 56.03143, -3.293878 56.02894, -…
#> 16 S08000030 board    MULTIPOLYGON (((-2.850836 56.97251, -2.8334 56.97687, -2.…
#> 17 S08000031 board    MULTIPOLYGON (((-4.499363 56.06133, -4.504911 56.06756, -…
#> 18 S08000032 board    MULTIPOLYGON (((-4.019864 56.02832, -4.030167 56.00963, -…
x[["plot"]](type = "interactive_map")
x[["plot_data"]](type = "interactive_map") #> Simple feature collection with 4 features and 2 fields #> Geometry type: POINT #> Dimension: XY #> Bounding box: xmin: -5.115637 ymin: 55.43402 xmax: -3.065759 ymax: 56.49556 #> CRS: NA #> # A tibble: 4 × 3 #> ID type geometry #> <chr> <chr> <POINT> #> 1 10002 gp (-3.065759 56.49556) #> 2 10017 gp (-3.84469 56.37021) #> 3 A101H hospital (-5.115637 55.54328) #> 4 A201H hospital (-4.593139 55.43402) x[["plot_info"]](type = "interactive_map") #> [1] "The interactive map below can be used to visualise individual GP\n practice or hospital data sets" ## ------------------------------------------------ ## Method `map$plot` ## ------------------------------------------------ x <- example_map_object() x[["plot"]](type = "interactive_map")
## ------------------------------------------------ ## Method `map$plot_data` ## ------------------------------------------------ x <- example_map_object() x[["plot_data"]](type = "interactive_map") #> Simple feature collection with 4 features and 2 fields #> Geometry type: POINT #> Dimension: XY #> Bounding box: xmin: -5.115637 ymin: 55.43402 xmax: -3.065759 ymax: 56.49556 #> CRS: NA #> # A tibble: 4 × 3 #> ID type geometry #> <chr> <chr> <POINT> #> 1 10002 gp (-3.065759 56.49556) #> 2 10017 gp (-3.84469 56.37021) #> 3 A101H hospital (-5.115637 55.54328) #> 4 A201H hospital (-4.593139 55.43402) ## ------------------------------------------------ ## Method `map$plot_info` ## ------------------------------------------------ x <- example_map_object() x[["plot_info"]](type = "interactive_map") #> [1] "The interactive map below can be used to visualise individual GP\n practice or hospital data sets"