Overview

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.

Summary

I have picked up an open source data for Indiaโ€™s population as per 2011 census and plotted all its states.

Read Data

setwd("~/Coursera/Developing Data Products") # Set working directory
India_map <- read.csv("state wise centroids_2011.csv", stringsAsFactors=FALSE) 

Load Libraries

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)

Plotting Data

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