On this page you find an interactive map of capital cities world wide. This based on a R Markdown document and uses leaflets to generate the map. The data presented in the map based on folowing data: http://techslides.com/demos/country-capitals.csv
I downloaded the date and stored it in file: country-capitals.csv.
Generate map with folowing code.
# load date
capital <- read.table(file = "./Dataset/country-capitals.csv"
, header = TRUE
, sep=","
, quote = "\""
)
# convert to dataframe
capitalDF <- data.frame(capital)
# convert column
capitalDF$CountryName <- as.character(capitalDF$CountryName)
capitalDF$CapitalName <- as.character(capitalDF$CapitalName)
capitalDF$CountryCode <- as.character(capitalDF$CountryCode)
# set popup text
capitalDF$popup <- paste(capitalDF$CapitalName,'<BR>(',capitalDF$CountryName,')')
# generate map
library(leaflet)
capitalMAP<- leaflet() %>% addTiles()
capitalMAP <- addMarkers(capitalMAP,
lng=capitalDF$CapitalLongitude,
lat = capitalDF$CapitalLatitude,
popup = capitalDF$popup,
label = capitalDF$CapitalName,
clusterOptions = markerClusterOptions()
)
Scroll in and out to see all capitals. Click on the pin to find out which country belongs to the Capital.