The goal of this project is to create a web page using R Markdown that features a map created with Leaflet. I have hosted my webpage on RPubs.
I have picked up an open source data for Indiaโs population as per 2011 census and plotted all its states.
setwd("~/Coursera/Developing Data Products") # Set working directory
India_map <- read.csv("state wise centroids_2011.csv", stringsAsFactors=FALSE)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(leaflet)
myMap <- India_map %>%
leaflet() %>%
addTiles() %>%
addMarkers(lat = India_map$Latitude , lng = India_map$Longitude, clusterOptions = markerClusterOptions(),
popup = paste("Region:", India_map$State, "<br>",
"Population (million):", India_map$Population_million,"<br>"))
myMap