Instructions

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! Review criterialess The rubric contains the following two questions:

  1. Does the web page feature a date and is this date less than two months before the date that you are grading this assignment?
  2. Does the web page feature an interactive map that appears to have been created with Leaflet?

Demenstration

This work aims to present the population with a circle on a map of the topography of 26 Brazilian capitals, followed by their respective units of the federation, along with its Federal District - DF, Brasília. The original data has been downloaded from the site:

  • sidra.ibge.gov.br : Sistema IBGE de Recuperação Automática. (IBGE - Brazilian Institute of Geography and Statistics).

Getting, selecting the data and performing the information processing:

# Access the data contained in a .csv text file.
geodata <- read.csv(file = "D:/Cursos/Courcera/_Johns Hopkins/__Data Science/_09- Developing Data Products/Data/PopResidUFBra_2007.csv", 
                    header = TRUE, 
                    sep = ";")
#Selects the 27 cities with the highest number of inhabitants.
my_map <- data.frame(city = geodata$City,
                     pop = c(geodata$Pop_2007),
                     lat = c(geodata$Latitude),
                     lng = c(geodata$Longitude)
                     )
# External package that provides provides a range of functions and axle labeling algorithms
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.2
map <- my_map %>%
  leaflet() %>%
  addTiles() %>%
  addMarkers(lng=my_map$lng, 
             lat=my_map$lat, 
             popup=paste(my_map$city, "<br>Population: ",
                         formatC(my_map$pop, format = "d", big.mark = ",")
                        )
            )%>%
# Displays the circle according to the population on the map..
  addCircles(lng    = my_map$lng, 
             lat    = my_map$lat, 
             weight = 1, 
             radius = (my_map$pop)/100, 
             popup  = strwrap(my_map$city)
            )
map