For my Leaflet Assignment in the Data Science Course of Johns Hopkins University, here I present the Gross Regional Domestic Product (GRDP) of the Philippines during the year 2017. Presented below is the map of the Philippines with blue markers representing its regions. Click on any marker and the name of the said region will pop up. Click on the region’s name and you will be redirected to its wikipedia page for more information. All regions also have colored circles on them which represents their GRDP. Red colored markers are for very high GRDP, Orange for high, Yellow for somewhat low and Green for Low. See the Legend provided on the upper right corner for the GRDP Upper and Lower limits for each Color.
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.5.2
library(xlsx)
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
data <- read.xlsx("Map.xlsx", sheetIndex = "Sheet1")
Coor <- data[,c(2,3)]
names <- data$Region
x <- cut2(data$GRDP, g = 4) %>% as.numeric
data$Color <- x
data$Color <- factor(data$Color)
data$Color<- factor(data$Color, levels = c("1", "2", "3", "4"), labels = c("green", "yellow", "orange", "red"))
Coor %>% leaflet() %>% addTiles() %>% addMarkers(popup = names) %>% addCircleMarkers(color = data$Color, weight = 1, radius = 25) %>% addLegend(labels = c("2017 Gross Regional Domestic Product", "Republic of the Philippines", "119 Million to < 312 Million","312 Million to < 488 Million","488 Million to < 1.03 Billion","1.03 Billion to 6.02 Billion"), colors = c("white","white", "green", "yellow", "orange", "red"))