http://www.opengeocode.org/download.php#cities
install.packages("dplyr",repos = "http://cran.us.r-project.org")
##
## The downloaded binary packages are in
## /var/folders/4z/9kr7k7jd1q7gc792xjkrwf040000gn/T//RtmpWCc7bv/downloaded_packages
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
install.packages("leaflet",repos = "http://cran.us.r-project.org")
##
## The downloaded binary packages are in
## /var/folders/4z/9kr7k7jd1q7gc792xjkrwf040000gn/T//RtmpWCc7bv/downloaded_packages
library(leaflet)
University_loc <- leaflet() %>%
addTiles() %>%
addMarkers(lng=-71.3247, lat=42.6549, popup="University of Massachussets, Lowell")
University_loc
setwd("/Users/janakiramsundaraneedi/Desktop")
world_cities<-read.csv("world_cities.csv")
head(world_cities)
## city city_ascii lat lng pop country iso2 iso3
## 1 Qal eh-ye Now Qal eh-ye 34.9830 63.1333 2997 Afghanistan AF AFG
## 2 Chaghcharan Chaghcharan 34.5167 65.2500 15000 Afghanistan AF AFG
## 3 Lashkar Gah Lashkar Gah 31.5830 64.3600 201546 Afghanistan AF AFG
## 4 Zaranj Zaranj 31.1120 61.8870 49851 Afghanistan AF AFG
## 5 Tarin Kowt Tarin Kowt 32.6333 65.8667 10000 Afghanistan AF AFG
## 6 Zareh Sharan Zareh Sharan 32.8500 68.4167 13737 Afghanistan AF AFG
## province
## 1 Badghis
## 2 Ghor
## 3 Hilmand
## 4 Nimroz
## 5 Uruzgan
## 6 Paktika
world_cities_usa <- world_cities %>% filter(country=='United States of America')
## Warning in filter_impl(.data, dots): '.Random.seed' is not an integer
## vector but of type 'NULL', so ignored
head(world_cities_usa)
## city city_ascii lat lng pop
## 1 Faribault Faribault 44.29049 -93.26801 24004.5
## 2 Mankato Mankato 44.16362 -93.99916 45731.5
## 3 Albert Lea Albert Lea 43.64779 -93.36870 19063.5
## 4 Willmar Willmar 45.12188 -95.04330 18432.0
## 5 Brainerd Brainerd 46.35801 -94.20085 21202.5
## 6 Crookston Crookston 47.77376 -96.60773 8215.5
## country iso2 iso3 province
## 1 United States of America US USA Minnesota
## 2 United States of America US USA Minnesota
## 3 United States of America US USA Minnesota
## 4 United States of America US USA Minnesota
## 5 United States of America US USA Minnesota
## 6 United States of America US USA Minnesota
dim(world_cities_usa)
## [1] 769 9
USA_Cities<-leaflet(world_cities_usa) %>% addTiles() %>%
addCircles(lng = ~lng, lat = ~lat, weight = 5,
radius = ~sqrt(pop) * 25, popup =~city)
USA_Cities
USA_Cities<-leaflet(world_cities_usa) %>% addProviderTiles("Stamen.Toner") %>%
addCircles(lng = ~lng, lat = ~lat, weight = 1,
radius = ~sqrt(pop) * 25, popup =~city)
USA_Cities