Create a web page using R Markdown that features a map created with Leaflet.
Host your webpage on either GitHub Pages, RPubs, or NeoCities.
Your webpage must contain the date that you created the document, and it must contain a map created with Leaflet. We would love to see you show off your creativity!
I will be looking at Largest cities by population with geographic Coordinates. My data is coming from : https://public.opendatasoft.com/explore/dataset/1000-largest-us-cities-by-population-with-geographic-coordinates/table/?sort=-rank. I will only be looking that the top five cities instead of all 1000 cities.
# library("readxl")
data <- read.csv("1000-largest-us-cities-by-population-with-geographic-coordinates.csv",
sep = ";")
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(tidyr)
library(leaflet)
library(htmltools)
newData <- data %>% separate(Coordinates,
c("Lat","Long"), sep = ",")
head(newData)
## City Rank State Growth.From.2000.to.2013 Population Lat
## 1 Marysville 552 Washington 115.7 63269 48.0517637
## 2 Perris 466 California 98.7 72326 33.7825194
## 3 Cleveland 48 Ohio -18.1 390113 41.49932
## 4 Worcester 129 Massachusetts 5.8 182544 42.2625932
## 5 Columbia 192 South Carolina 11.7 133358 34.0007104
## 6 Waterbury 253 Connecticut 2.2 109676 41.5581525
## Long
## 1 -122.1770818
## 2 -117.2286478
## 3 -81.6943605
## 4 -71.8022934
## 5 -81.0348144
## 6 -73.0514965
my_map <- leaflet() %>% addTiles()
my_map <- my_map %>% addMarkers(lat=48.0517637, lng= -122.1770818, popup="1st highest")
my_map <- my_map %>% addMarkers(lat=33.7825194, lng= -117.2286478, popup="2nd highest")
my_map <- my_map %>% addMarkers(lat=41.49932, lng= -81.6943605, popup="3rd highest")
my_map <- my_map %>% addMarkers(lat=42.2625932, lng= -71.8022934, popup="4th highest")
my_map <- my_map %>% addMarkers(lat=34.0007104, lng= -81.0348144, popup="5th highest")
my_map