This document is for the submission for Developing Data Products - Week 2 Assignment. The project is for creating a webpage using R markdown that features a map created with Leaflet.
I have created an interactive map using Leaflet. The map displays the cities from USA and shows the cities with population greater than 1,000,000.
Let’s start with loading necessary packages
library(leaflet)
library(maps)
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
I am using dataset world embedded in r for this assignment.
data(world.cities)
Next code is to setup leaflet map.
leaflet(world.cities %>%
dplyr::filter(
country.etc == "USA",
pop > 1000000
)) %>%
addTiles() %>%
addMarkers(lat = ~lat, lng = ~long, popup=~name, clusterOptions = markerClusterOptions())