Browse Source

Crude map

Petra Lamborn 4 years ago
parent
commit
7d1ec5cc1b
1 changed files with 28 additions and 0 deletions
  1. 28
    0
      MedicalCentres/app.R

+ 28
- 0
MedicalCentres/app.R View File

@@ -0,0 +1,28 @@
1
+library(shiny)
2
+library(leaflet)
3
+library(janitor)
4
+library(dplyr)
5
+library(readr)
6
+
7
+Geo2017 <- clean_names(read_csv("../data/AllDHBsGeocoded.csv"), case = "snake") %>%
8
+    select(-facility_opening_date) %>%
9
+    mutate(dhb_name = ifelse(is.na(dhb_name), "Missing", dhb_name),
10
+           health_facility_code = ifelse(is.na(health_facility_code),
11
+                                         "Missing", health_facility_code))
12
+
13
+ui <- fillPage(
14
+    leafletOutput(outputId = "medmap", height = "100%")
15
+)
16
+
17
+server <- function(input, output) {
18
+    output$medmap <- renderLeaflet({
19
+        leaflet(Geo2017) %>%
20
+            addTiles() %>%
21
+            addMarkers(lng = Geo2017$lon,
22
+                       lat = Geo2017$lat,
23
+                       popup = Geo2017$name)
24
+    })
25
+}
26
+
27
+# Run the application 
28
+shinyApp(ui = ui, server = server)