library(leaflet)
library(dplyr)
library(magrittr)
library(stringr)
library(ggmap)
Load data from file contains names of Tipat Halav clinics and number of patients in each by age.
data <- readxl::read_xlsx("~/Downloads/milkstation.xlsx", skip = 1)
names(data) <- c("station", "below_1", "1-2", "2-3", "3-4", "above_4", "sum")
# Remove districts summarize
data %<>% filter(sum < 10000)
data %>% rmarkdown::paged_table()
Search the name of each station in Google Maps, and save the coordinates.
Save the result in file for not recall the API.
APIkey <- readLines("~/Downloads/googleMapsAPIkey.txt")
register_google(APIkey)
if(!file.exists("~/Downloads/milkstation_coordinates.csv")){
data %<>% data.frame(geocode(data$station))
data %<>% filter(lon > 30)
write.csv(data, "~/Downloads/milkstation_coordinates.csv")
} else { data <- read.csv("~/Downloads/milkstation_coordinates.csv") }
data %>% leaflet(height = 1000, width = 900) %>% addTiles() %>%
addMarkers(~lon, ~lat, label = ~station, clusterOptions = markerClusterOptions())