Introduction

The objective of this assignment is to create a web page using R Markdown that features a map created with Leaflet. The webpage needs to be hosted on either GitHub Pages, RPubs, or NeoCities. I chose to host it on RPubs.

Loading required libraries

library(leaflet)
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

Marking the capitals of the seven states of Northeast India and visualizing their population data

We will use a dataset which has been sourced from the website “https://simplemaps.com/data/in-cities”. The dataset will be loaded into a dataframe and it will be used to mark the capitals of seven states of Northeast India along with visualization of their population.

dfcities <- read.csv('in.csv')
dfcities
##       city     lat     lng country iso2             State capital population
## 1 Guwahati 26.1667 91.7667   India   IN             Assam             957352
## 2 Agartala 23.8333 91.2667   India   IN           Tripura   admin     522613
## 3   Aizawl 23.7104 92.7200   India   IN           Mizoram   admin     283021
## 4   Imphal 24.8200 93.9500   India   IN           Manipur   admin     268243
## 5  Gangtok 27.3300 88.6200   India   IN            Sikkim   admin     100286
## 6   Kohima 25.6667 94.1194   India   IN          Nagaland   admin      99039
## 7 Itanagar 27.1000 93.6200   India   IN Arunachal Pradesh   admin      59490
##   population_proper
## 1            957352
## 2            522613
## 3            265331
## 4            268243
## 5            100286
## 6             99039
## 7             59490

We observe that the dataset contains data for the Capitals of the seven states of Northeast India. We proceed for generating the map marking these cities and visualizing their populations with circles.

dfcities %>% leaflet() %>% addTiles() %>% addCircles(weight = 1, radius = sqrt(dfcities$population) * 30) %>% addMarkers(lat=dfcities$lat, lng = dfcities$lng, popup=paste(dfcities$city, dfcities$State, sep = ", "))
## Assuming "lng" and "lat" are longitude and latitude, respectively