library(leaflet)
icon <- makeIcon("https://image.flaticon.com/icons/svg/141/141744.svg", iconWidth = 22, iconHeight = 20, iconAnchorX = 19, iconAnchorY = 20)
lat <- c( 40.7127837, 34.0522342, 41.8781136, 29.7604267, 39.9525839)
lon <- c(-74.0059413, -118.2436849, -87.6297982,-95.3698028, -75.1652215 )
city <- c('New York City','Los Angeles',"Chicago", "Houston",'Philadelphia' )
Population <- c(8405837, 3884307, 2718782,2195914, 1553165)
df <- data.frame(name = city, pop = Population, lat = lat, lng = lon)
df
## name pop lat lng
## 1 New York City 8405837 40.71278 -74.00594
## 2 Los Angeles 3884307 34.05223 -118.24368
## 3 Chicago 2718782 41.87811 -87.62980
## 4 Houston 2195914 29.76043 -95.36980
## 5 Philadelphia 1553165 39.95258 -75.16522
df %>% leaflet() %>% addTiles %>% addMarkers(icon = icon)
## Assuming "lng" and "lat" are longitude and latitude, respectively
df %>% leaflet() %>% addTiles %>% addCircles(weight = 10, radius = sqrt(df$pop)*50) %>% addLegend(labels = df$name, colors = c('pink','purple','blue','green','yellow'))
## Assuming "lng" and "lat" are longitude and latitude, respectively
###### draw circles