Module 46 Mapping

Group exercise

  1. Create a new rmarkdown document.

  2. Create a code chunk. In this chunk, read in some data on “conflicts”. This data comes from https://ucdp.uu.se/encyclopedia. Take a minute or two to look at the website. To read in the data, run the below code.

library(dplyr)
download.file('https://raw.githubusercontent.com/databrew/intro-to-data-science/main/data/conflicts.RData',
              destfile = 'conflicts.RData')
load('conflicts.RData')
  1. Have a look in the data. Which fields are likely to be geographic?

  2. Make a simple x-y plot using geographic fields.

  3. Create an object named conflicts_afg. This should be a plot of conflicts in Afghanistan.

  4. Color the points by year.

  5. Instead of year, color the points by deaths_civilians.

  6. Color the points by date, but make point size reflect deaths_civilians.

  7. Create a leaflet map of conflicts in a country of your choice.

  8. Use addTiles.

  9. Use addProviderTiles to make your map a satellite map.

  10. Explore other tiles

  11. Add pop-ups to your maps by using the popup argument within addMarkers.

  12. Add clusterOptions = markerClusterOptions() to make your points clustered.

  13. Replace your markers with “circle markers”.

  14. Create a shiny app wherein the user selects a country and time frame, and the app shows both (a) an interactive map and (b) a plot of the number of conflicts by year for that country.