Module 46 Mapping
Group exercise
Create a new rmarkdown document.
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')
Have a look in the data. Which fields are likely to be geographic?
Make a simple x-y plot using geographic fields.
Create an object named
conflicts_afg
. This should be a plot of conflicts in Afghanistan.Color the points by year.
Instead of year, color the points by
deaths_civilians
.Color the points by date, but make point size reflect
deaths_civilians
.Create a leaflet map of conflicts in a country of your choice.
Use
addTiles
.Use
addProviderTiles
to make your map a satellite map.Explore other tiles
Add pop-ups to your maps by using the
popup
argument withinaddMarkers
.Add
clusterOptions = markerClusterOptions()
to make your points clustered.Replace your markers with “circle markers”.
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.