Last updated: 2020-12-17

Checks: 7 0

Knit directory: GeoPKO/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200629) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version ae55a70. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    figure/

Unstaged changes:
    Modified:   data/Geo_PKO_v.2.0.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/merge.Rmd) and HTML (docs/merge.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd ae55a70 Nguyen Ha 2020-12-17 building merge page to fix kable table
html 0c74087 Nguyen Ha 2020-12-15 Build site.
Rmd 550bf6b Tanushree Rao 2020-12-15 these are my real updates to the merge page
html 7bac7dd Nguyen Ha 2020-12-14 Build site.
Rmd 927a18a Nguyen Ha 2020-12-14 publishing merge page with edits
html 0a147a1 Nguyen Ha 2020-12-14 Build site.
Rmd 9408512 Nguyen Ha 2020-12-14 revising merge script for views; prebuild
html 9408512 Nguyen Ha 2020-12-14 revising merge script for views; prebuild
Rmd 9652a69 Tanushree Rao 2020-12-14 merge page update v2 including labels only for deployments and updating text to clarify
Rmd 74c5349 Tanushree Rao 2020-12-14 merge page update v1 with troops averaged over prioid
html 885e0d5 Nguyen Ha 2020-12-09 Build site.
Rmd 18bad54 Nguyen Ha 2020-12-09 updating nav bar
html 263d508 Nguyen Ha 2020-12-09 Build site.
html 045b912 Nguyen Ha 2020-12-09 Build site.
Rmd 3059f09 Nguyen Ha 2020-12-09 merged, also fixed outwidth
html 3059f09 Nguyen Ha 2020-12-09 merged, also fixed outwidth
Rmd d436446 Tanushree Rao 2020-12-09 fixing issues with old and new merge page
Rmd 7a7271b Nguyen Ha 2020-12-09 merging gallery
Rmd 3c91f39 Nguyen Ha 2020-12-09 commit before pulling to build
html 3c91f39 Nguyen Ha 2020-12-09 commit before pulling to build
Rmd 6a20fd9 Lou van Roozendaal 2020-12-04 update global animated map
html c0b0ce3 Nguyen Ha 2020-12-03 Build site.
Rmd ee18491 Nguyen Ha 2020-12-03 minor edit
html a966566 Nguyen Ha 2020-12-03 Build site.
Rmd eafa002 Nguyen Ha 2020-12-03 adapting to new dataset version
Rmd 5502ba6 Lou van Roozendaal 2020-11-26 UpdateUCDP
Rmd c69de3a Tanushree Rao 2020-11-25 minor text updates + removing warning messages
Rmd 7cd68d8 Tanushree Rao 2020-11-25 minor edits, removing warning messages
html acee4ed Nguyen Ha 2020-11-25 Build site.
Rmd b6fea7a Nguyen Ha 2020-11-25 Revised viz, index, incorporated merge attempt 2.rmd
html 2011bda Nguyen Ha 2020-11-25 Build site.
Rmd 448b94c Nguyen Ha 2020-11-25 Revised viz, index, incorporated merge.rmd
Rmd ad652a3 Tanushree Rao 2020-11-24 changed ref to geopko so it opens with v1 data
Rmd 6d15379 Tanushree Rao 2020-11-24 updating merge page with new data
Rmd 2608fc0 Tanushree Rao 2020-09-10 merge file
Rmd 9174a7c Tanushree Rao 2020-09-09 adding kables
Rmd 113774e Tanushree Rao 2020-09-04 edits to data
Rmd 5afdf38 Tanushree Rao 2020-09-03 adding merge page

This page shows how to merge Geo-PKO data with conflict data and visualise the results. The examples used here are Uppsala University’s Violence Early Warning System (ViEWS) project, which forecasts conflict risk, and the Uppsala Conflict Data Programme (UCDP), one of the world’s leading sources of data on armed conflict. Merging these datasets can provide insights into the links between conflict risk and peacekeeping deployments, and help policymakers make effective peacekeeping decisions where the risk of conflict is high.

Geo-PKO x ViEWS

Our goal is to show peacekeeping deployments in 2019 and predicted conflict risks for July 2020 – six months later. It helps us visualise conflict forecasts for locations where peacekeepers are deployed and better understand the relationship between peacekeeping deployments and conflict risk.

First, we import the datasets. We’re using the published Geo-PKO dataset version 2.0, and conflict forecast data provided by ViEWS. The latter includes predicted risks of state-based conflict, non-state conflict, and one-sided violence in Africa. ViEWS’ data is collected by PRIO-grid – a geospatial unit from the Peace Research Institute Oslo that divides the world into roughly 55km x 55km squares, allowing geographic analysis beyond the country level to be streamlined. Note that the predictions of violence from ViEWS do not account for the presence of peacekeeping missions.

library(readr)

geopko <- readr::read_csv("data/Geo_PKO_v.2.0.csv") 
#unzip("data/ViEWS.zip", exdir="data/ViEWS")
predictors <- readr::read_csv("data/ViEWS/ensemble_pgm.csv")

The Geo-PKO dataset includes detail on troop deployment numbers, types of troops, non-troop deployments, and contributing countries.

library(kableExtra)
kable(geopko[9546:9555,]) %>% kable_styling() %>%
  scroll_box(width = "100%", height = "400px")
source mission year month location geosplit country latitude longitude old_xy geocomment zone.de.confidence battalion company platoon other.size comment.on.unit no.troops rpf rpf.no inf inf.no fpu fpu.no res res.no fp fp.no eng sig trans riv he.sup sf med maint recon avia mp demining uav obs.base cantonment disarmament other.type armor he.sup.lw troop.type no.tcc nameoftcc_1 notroopspertcc_1 nameoftcc_2 notroopspertcc_2 nameoftcc_3 notroopspertcc_3 nameoftcc_4 notroopspertcc_4 nameoftcc_5 notroopspertcc_5 nameoftcc_6 notroopspertcc_6 nameoftcc_7 notroopspertcc_7 nameoftcc_8 notroopspertcc_8 nameoftcc_9 notroopspertcc_9 nameoftcc_10 notroopspertcc_10 nameoftcc_11 notroopspertcc_11 nameoftcc_12 notroopspertcc_12 nameoftcc_13 notroopspertcc_13 nameoftcc_14 notroopspertcc_14 nameoftcc_15 notroopspertcc_15 nameoftcc_16 notroopspertcc_16 nameoftcc_17 notroopspertcc_17 unpol.dummy unmo.dummy unmo.coding.quality hq lo jmco security.group.dummy comments cow_code gnwo tcc1 tcc2 tcc3 tcc4 tcc5 tcc6 tcc7 tcc8 tcc9 tcc10 tcc11 tcc12 tcc13 tcc14 tcc15 tcc16 tcc17 adm1.id adm1.name prioid
Map no. 4249 Rev. 08 UNMIS 2007 8 Bentiu 0 Sudan 9.233333 29.83333 NA GNS has two locations pointing to basically the same place. I took the coords for “seat of first-order admin division”, rahter than “populated place”, both are in line with GE. Also, today’s south sudan NA 0 1 0 0 NA 150 NA NA 1 150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 0 0 NA 1 1 India 150 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 0 0 FALSE 0 NA 625 625 750 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 622 Unity 142980
Map no. 4249 Rev. 08 UNMIS 2007 8 Bor 0 Sudan 6.205931 31.55633 NA GNS has two locations, the “seat of first-order admin division” pointing to location of Google Earth by same name, as well as corresponding to source map, hence that one coded. Also, today’s south sudan NA 0 0 0 0 NA 0 NA NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 0 0 NA 0 0 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 0 0 FALSE 0 NA 625 625 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 621 Jungoli 138664
Map no. 4249 Rev. 08 UNMIS 2007 8 Dilling 0 Sudan 12.050000 29.65000 NA NA NA 0 0 0 0 NA 0 NA NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 0 0 NA 0 0 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 0 0 FALSE 0 NA 625 625 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 720 South Kordufan 147300
Map no. 4249 Rev. 08 UNMIS 2007 8 Ed Damazin 0 Sudan 11.789100 34.35920 NA NA NA 1 4 0 0 NA 1250 NA NA 1 650 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 NA NA NA 0 0 NA 1, 2, 4, 11, 14 1 Pakistan 1250 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 2 0 FALSE 0 NA 625 625 770 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 287 Blue Nile 146589
Map no. 4249 Rev. 08 UNMIS 2007 8 El Obeid 0 Sudan 13.183333 30.21667 NA NA NA 0 1 0 0 NA 150 NA NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 1 0 NA 99 0 unknown 150 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 0 NA 0 0 FALSE 0 “other” troop type refers to LOG company, unknown TCC 625 625 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 721 North Kordufan 148741
Map no. 4249 Rev. 08 UNMIS 2007 8 Juba 0 Sudan 4.845972 31.60120 NA today’s south sudan NA 1 7 0 0 NA 1700 NA NA 1 650 0 0 1 150 0 0 1 0 1 0 0 0 0 0 0 1 1 1 0 NA NA NA 1 0 NA 1, 2, 4, 11, 13, 14, 15, 99 3 Bangladesh 1400 India 150 Russia 150 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 2 0 TRUE 0 Reserve = FRB 1 company (TCC India), troop type other refers 1 AMET company (Bangladesh), 625 625 771 750 365 NA NA NA NA NA NA NA NA NA NA NA NA NA NA 619 Central Equatoria 136504
Map no. 4249 Rev. 08 UNMIS 2007 8 Julud 0 Sudan 11.974816 29.34032 NA GNS/Google Earth not found, estimated on GE based on source map. NA 0 0 0 0 NA 0 NA NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 0 0 NA 0 0 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 0 0 FALSE 0 NA 625 625 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 720 South Kordufan 146579
Map no. 4249 Rev. 08 UNMIS 2007 8 Kadugli 0 Sudan 11.016667 29.71667 NA NA NA 1 5 0 0 NA 1400 NA NA 1 150 0 0 1 650 0 0 1 0 0 0 0 0 1 0 0 1 0 1 0 NA NA NA 0 0 NA 1, 2, 8, 11, 14, 15 2 Egypt 600 India 800 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 2 0 FALSE 0 Reserve = FRB 1 batallion (India) 625 625 651 750 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 720 South Kordufan 145860
Map no. 4249 Rev. 08 UNMIS 2007 8 Kauda 0 Sudan 11.100000 30.51667 NA NA NA 0 0 0 0 NA 0 NA NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 0 0 NA 0 0 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0 1 0 0 0 FALSE 0 NA 625 625 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 720 South Kordufan 145862
Map no. 4249 Rev. 08 UNMIS 2007 8 Khartoum 0 Sudan 15.588056 32.53417 NA NA NA 1 0 0 0 NA 650 NA NA 1 650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA NA NA 0 0 NA 1 1 Rwanda 650 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 1 1 0 3 0 FALSE 0 NA 625 625 517 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 712 Khartoum 152346

Preparing the data

We first need to filter the Geo-PKO data to include only observations for the year 2019, the latest year in version 2.0. We also remove countries outside Africa, as the ViEWS dataset only covers this continent.

# Load packages.

library(dplyr)
library(tidyr)
library(broom)

# filtering for troop deployments for the year 2019 in Africa

geopko2 <- geopko %>%
  filter(year=="2019") %>% 
  # subsetting columns so we have a smaller data frame to work with
  select(mission, prioid, no.troops, country, location, latitude, longitude) %>%
  # making sure the class for numeric variables is set to numeric
  dplyr::mutate_at(vars(longitude, latitude, no.troops), as.numeric) %>%
  # filtering out missions that did not take place in Africa
  filter(!(country %in% c("Kosovo", "Lebanon", "Haiti", "Syria", "Cyprus", "Israel")))

# for a list of host countries in the Geo-PKO dataset, you can run the following:
# geopko %>% distinct(country)

We now need to calculate the average number of troops deployed over that time period. In the visualisation, we’ll use coordinates to map every single deployment locations, so the average is calculated by location. In the next step, we also use this number to calculate the average number of deployed troops for each PRIO-grid square. As a PRIO-grid square is geographically large, one grid square may have been home to multiple locations. We won’t visualise this bit of data here, but this is useful for understanding how to synthesise datasets with different units of analysis.

# calculating an average number of troops per location

geopko2 <- geopko2 %>%
  group_by_at(vars(-no.troops)) %>%
  dplyr::summarise(no.troops.yearly.avr = round(mean(no.troops, na.rm=TRUE))) %>%
  ungroup() %>% 
# summing the troop count for each prio grid
  group_by(prioid) %>%
  dplyr::mutate(no.troops.prio = sum(no.troops.yearly.avr, na.rm=TRUE)) %>%
  ungroup()

The predictor database begins with July 2020 and forecasts the risk of conflict over the next 36 months ahead. Here’s a preview of the data within it, showing state-based (sb), non-state (ns) and one-sided violence (os) forecasts. The variable month_id codes months differently to the Geo-PKO dataset, with every month assigned a different numeric value.

kable(predictors[90545:90555,]) %>% kable_styling() %>%
  scroll_box(width = "100%", height = "400px")
month_id pg_id average_allwthematic_sb average_allwthematic_ns average_allwthematic_os
494 141560 0.0056672 0.0040548 0.0049985
494 141561 0.0054137 0.0032145 0.0038274
494 141562 0.0115811 0.0073864 0.0045633
494 141563 0.0093885 0.0043294 0.0027875
494 141564 0.0085510 0.0184678 0.0043437
494 141565 0.0098269 0.0046215 0.0037409
494 141566 0.0091474 0.0039857 0.0029673
494 141567 0.0080367 0.0052120 0.0036094
494 141568 0.0169302 0.0046075 0.0047167
494 141569 0.0102886 0.0049955 0.0038738
494 141570 0.0074703 0.0045105 0.0040073

You’ll see both the Geo-PKO and ViEWS datasets include the PRIO-grid identification variable (pg_id or prioid), which corresponds to a specific grid square on the map. This is what we’ll use to eventually merge the datasets. For now, we subset the ViEWS predictions to include only the month of July 2020, which gives us a lagged time period of six months between the Geo-PKO observations and ViEWS predictions.

predictors2 <- predictors %>% 
  filter(month_id==487) 

Finally, we merge the two datasets.

priogriddf <- left_join(
  predictors2, geopko2, 
  by = c("pg_id"="prioid"), 
  name="pg_id")

Merging the dataframe with the shapefile

Like we mentioned before, the PRIO-grid unit involves dividing the entire world into roughly 55km x 55 km squares. That means that if we want to map it, we’ll be working with large files, so keep that in mind when you’re reading in the shapefile.

# loading R packages that we can use to handle shapefiles

library(rgdal)
library(sp)
library(sf)
library(ggplot2)
library(spdep)
library(rjson)
library(RJSONIO)
library(rmapshaper)
library(geojsonio)

shapefile <- rgdal::readOGR("data/ViEWS/priogrid.geojson")

The shapefile contains both geospatial polygon data and numerical data that corresponds to the ViEWS dataset; specifically, a PRIO-grid ID and a country ID. To work with the data within this shapefile, we need to fortify it. This converts it into a dataframe. We also convert the IDs to rownames to make it easier to work with. And, finally, we merge it with priogriddf, which we created earlier.

# fortify
shapefile@data$id <- rownames(shapefile@data)
shapefile.df <- fortify(shapefile, region = "id")

# merge data
shapefile.df <- merge(shapefile, priogriddf, by.x = "pg_id", by.y = "pg_id", all.x=F, all.y=T, duplicateGeoms=TRUE)

Now shapefile.df has the new attributes, including variables from both Geo-PKO and ViEWS. id is a variable that ties the ‘polygon’, or a single square on the grid, to its location on the map. As many PRIO-grid squares will have a conflict forecast index but no troop deployments, many data points under Geo-PKO variables will show NA.

kable(shapefile.df@data[5386:5500,]) %>% kable_styling() %>%
  scroll_box(width = "100%", height = "400px")
pg_id id month_id average_allwthematic_sb average_allwthematic_ns average_allwthematic_os mission country location latitude longitude no.troops.yearly.avr no.troops.prio
5386 142960 16815 487 0.0041708 0.0022700 0.0041500 NA NA NA NA NA NA NA
5387 142961 16816 487 0.0042074 0.0018461 0.0022557 NA NA NA NA NA NA NA
5388 142962 16817 487 0.0026193 0.0018622 0.0033322 NA NA NA NA NA NA NA
5389 142963 16818 487 0.0025915 0.0023179 0.0032477 NA NA NA NA NA NA NA
5390 142964 16819 487 0.0025523 0.0021788 0.0039589 NA NA NA NA NA NA NA
5391 142965 16820 487 0.0024563 0.0018451 0.0029490 NA NA NA NA NA NA NA
5392 142966 16821 487 0.0027910 0.0023940 0.0040094 NA NA NA NA NA NA NA
5393 142967 16822 487 0.0031288 0.0033322 0.0036037 NA NA NA NA NA NA NA
5394 142968 16823 487 0.0052934 0.0058282 0.0050818 NA NA NA NA NA NA NA
5395 142969 16824 487 0.0233679 0.0059153 0.0074611 NA NA NA NA NA NA NA
5396 142970 16825 487 0.0052546 0.0025777 0.0031888 NA NA NA NA NA NA NA
5397 142971 16826 487 0.0032189 0.0021892 0.0024438 NA NA NA NA NA NA NA
5398 142972 16827 487 0.0034409 0.0023891 0.0025170 NA NA NA NA NA NA NA
5399 142973 16828 487 0.0043548 0.0033392 0.0029624 NA NA NA NA NA NA NA
5400 142974 16829 487 0.0056272 0.0060042 0.0034519 UNISFA Sudan Gok-machar 9.215412 26.85991 0 0
5401 142975 16830 487 0.0065574 0.0038209 0.0034270 NA NA NA NA NA NA NA
5402 142976 16831 487 0.0175208 0.0059172 0.0052166 NA NA NA NA NA NA NA
5403 142977 16832 487 0.0066656 0.0077472 0.0051547 UNISFA Sudan Athony 9.470559 28.46404 335 335
5404 142978 16833 487 0.0059170 0.0477347 0.0056441 UNISFA Sudan Agok 9.357486 28.58258 128 278
5405 142978 16833 487 0.0059170 0.0477347 0.0056441 UNISFA Sudan Marial Achak 9.479328 28.62492 150 278
5406 142979 16834 487 0.0101605 0.0384437 0.0078164 NA NA NA NA NA NA NA
5407 142980 16835 487 0.0152777 0.0066472 0.0103604 UNMISS South Sudan Bentiu 9.259905 29.80011 1493 1493
5408 142981 16836 487 0.0058057 0.0027743 0.0033286 NA NA NA NA NA NA NA
5409 142982 16837 487 0.0062693 0.0039518 0.0041326 NA NA NA NA NA NA NA
5410 142983 16838 487 0.0066816 0.0035258 0.0046490 NA NA NA NA NA NA NA
5411 142984 16839 487 0.0102477 0.0052673 0.0051385 NA NA NA NA NA NA NA
5412 142985 16840 487 0.0059767 0.0037912 0.0041777 NA NA NA NA NA NA NA
5413 142986 16841 487 0.0054720 0.0034994 0.0027903 NA NA NA NA NA NA NA
5414 142987 16842 487 0.0081251 0.0034510 0.0050982 NA NA NA NA NA NA NA
5415 142988 16843 487 0.0043364 0.0032736 0.0026790 NA NA NA NA NA NA NA
5416 142989 16844 487 0.0100904 0.0039397 0.0055538 NA NA NA NA NA NA NA
5417 142990 16845 487 0.0094131 0.0134821 0.0064823 NA NA NA NA NA NA NA
5418 142991 16846 487 0.0091791 0.0048284 0.0073076 NA NA NA NA NA NA NA
5419 142992 16847 487 0.0161389 0.0074493 0.0320516 NA NA NA NA NA NA NA
5420 142993 16848 487 0.0066236 0.0081516 0.0043451 NA NA NA NA NA NA NA
5421 142994 16849 487 0.0324704 0.0057236 0.0141111 NA NA NA NA NA NA NA
5422 142995 16850 487 0.0064076 0.0040675 0.0053015 NA NA NA NA NA NA NA
5423 142996 16851 487 0.0057431 0.0037162 0.0081695 NA NA NA NA NA NA NA
5424 142997 16852 487 0.0088671 0.0047508 0.0153229 NA NA NA NA NA NA NA
5425 142998 16853 487 0.0319674 0.0153954 0.0403500 NA NA NA NA NA NA NA
5426 142999 16854 487 0.0066367 0.0038534 0.0064316 NA NA NA NA NA NA NA
5427 143000 16855 487 0.0059746 0.0041465 0.0052594 NA NA NA NA NA NA NA
5428 143001 16856 487 0.0095470 0.0060067 0.0219970 NA NA NA NA NA NA NA
5429 143002 16857 487 0.0117410 0.0077639 0.0113292 NA NA NA NA NA NA NA
5430 143003 16858 487 0.0125031 0.0066934 0.0107884 NA NA NA NA NA NA NA
5431 143004 16859 487 0.0126402 0.0058383 0.0124720 NA NA NA NA NA NA NA
5432 143005 16860 487 0.0160709 0.0299349 0.0287005 NA NA NA NA NA NA NA
5433 143006 16861 487 0.0129451 0.0130849 0.0114596 NA NA NA NA NA NA NA
5434 143007 16862 487 0.0098104 0.0052613 0.0086665 NA NA NA NA NA NA NA
5435 143008 16863 487 0.0086536 0.0061202 0.0060146 NA NA NA NA NA NA NA
5436 143009 16864 487 0.0082165 0.0048765 0.0045290 NA NA NA NA NA NA NA
5437 143010 16865 487 0.0081052 0.0042040 0.0046078 NA NA NA NA NA NA NA
5438 143011 16866 487 0.0077113 0.0033373 0.0031191 NA NA NA NA NA NA NA
5439 143012 16867 487 0.0077103 0.0032003 0.0030833 NA NA NA NA NA NA NA
5440 143013 16868 487 0.0069547 0.0033479 0.0032337 NA NA NA NA NA NA NA
5441 143014 16869 487 0.0082141 0.0048571 0.0030324 NA NA NA NA NA NA NA
5442 143015 16870 487 0.0137645 0.0055326 0.0035717 NA NA NA NA NA NA NA
5443 143016 16871 487 0.0109393 0.0051010 0.0085441 NA NA NA NA NA NA NA
5444 143017 16872 487 0.0072327 0.0033817 0.0033521 NA NA NA NA NA NA NA
5445 143018 16873 487 0.0079271 0.0092717 0.0037476 NA NA NA NA NA NA NA
5446 143019 16874 487 0.0069960 0.0038786 0.0026167 NA NA NA NA NA NA NA
5447 143020 16875 487 0.0067167 0.0038825 0.0023772 NA NA NA NA NA NA NA
5448 143021 16876 487 0.0066711 0.0034388 0.0022679 NA NA NA NA NA NA NA
5449 143022 16877 487 0.0060705 0.0023059 0.0023155 NA NA NA NA NA NA NA
5450 143612 16951 487 0.0029709 0.0016675 0.0024115 NA NA NA NA NA NA NA
5451 143613 16952 487 0.0081795 0.0039790 0.0186863 NA NA NA NA NA NA NA
5452 143614 16953 487 0.0053077 0.0036424 0.0069272 NA NA NA NA NA NA NA
5453 143615 16954 487 0.0033039 0.0018145 0.0037121 NA NA NA NA NA NA NA
5454 143616 16955 487 0.0042989 0.0017846 0.0041232 NA NA NA NA NA NA NA
5455 143617 16956 487 0.0044655 0.0017693 0.0047451 NA NA NA NA NA NA NA
5456 143618 16957 487 0.0045482 0.0018236 0.0045708 NA NA NA NA NA NA NA
5457 143619 16958 487 0.0040128 0.0018725 0.0035781 NA NA NA NA NA NA NA
5458 143620 16959 487 0.0035636 0.0021476 0.0033513 NA NA NA NA NA NA NA
5459 143621 16960 487 0.0030958 0.0020440 0.0036755 NA NA NA NA NA NA NA
5460 143622 16961 487 0.0033988 0.0020086 0.0032572 NA NA NA NA NA NA NA
5461 143623 16962 487 0.0029432 0.0016806 0.0030611 NA NA NA NA NA NA NA
5462 143624 16963 487 0.0030906 0.0019130 0.0034069 NA NA NA NA NA NA NA
5463 143625 16964 487 0.0039628 0.0024349 0.0037574 NA NA NA NA NA NA NA
5464 143626 16965 487 0.0029263 0.0015856 0.0023600 NA NA NA NA NA NA NA
5465 143627 16966 487 0.0029063 0.0017700 0.0026404 NA NA NA NA NA NA NA
5466 143628 16967 487 0.0031722 0.0024256 0.0028054 NA NA NA NA NA NA NA
5467 143629 16968 487 0.0034927 0.0026055 0.0033033 NA NA NA NA NA NA NA
5468 143630 16969 487 0.0078417 0.0036194 0.0048938 NA NA NA NA NA NA NA
5469 143631 16970 487 0.0061211 0.0020662 0.0031933 NA NA NA NA NA NA NA
5470 143632 16971 487 0.0109527 0.0028633 0.0071014 NA NA NA NA NA NA NA
5471 143633 16972 487 0.0035168 0.0019306 0.0023826 NA NA NA NA NA NA NA
5472 143634 16973 487 0.0039251 0.0025900 0.0032226 NA NA NA NA NA NA NA
5473 143635 16974 487 0.0049813 0.0031815 0.0049153 NA NA NA NA NA NA NA
5474 143636 16975 487 0.0031462 0.0021498 0.0028122 NA NA NA NA NA NA NA
5475 143637 16976 487 0.0028945 0.0021488 0.0021162 NA NA NA NA NA NA NA
5476 143638 16977 487 0.0030254 0.0025331 0.0028764 NA NA NA NA NA NA NA
5477 143639 16978 487 0.0038057 0.0027593 0.0031568 NA NA NA NA NA NA NA
5478 143640 16979 487 0.0031926 0.0029556 0.0028334 NA NA NA NA NA NA NA
5479 143641 16980 487 0.0053824 0.0036204 0.0048873 NA NA NA NA NA NA NA
5480 143642 16981 487 0.0033809 0.0022457 0.0032509 NA NA NA NA NA NA NA
5481 143643 16982 487 0.0060991 0.0038097 0.0078825 NA NA NA NA NA NA NA
5482 143644 16983 487 0.0037208 0.0026076 0.0045553 NA NA NA NA NA NA NA
5483 143645 16984 487 0.0030568 0.0022365 0.0026860 NA NA NA NA NA NA NA
5484 143646 16985 487 0.0034846 0.0018022 0.0023535 NA NA NA NA NA NA NA
5485 143647 16986 487 0.0034904 0.0022028 0.0060601 NA NA NA NA NA NA NA
5486 143648 16987 487 0.0061668 0.0069707 0.0059635 NA NA NA NA NA NA NA
5487 143649 16988 487 0.0062818 0.0086873 0.0070751 NA NA NA NA NA NA NA
5488 143650 16989 487 0.0079287 0.0095098 0.0042095 NA NA NA NA NA NA NA
5489 143651 16990 487 0.0278620 0.0120654 0.0092928 NA NA NA NA NA NA NA
5490 143652 16991 487 0.0148061 0.0112556 0.0222652 NA NA NA NA NA NA NA
5491 143653 16992 487 0.0214251 0.0417365 0.0385439 NA NA NA NA NA NA NA
5492 143654 16993 487 0.0510529 0.0475627 0.0258935 NA NA NA NA NA NA NA
5493 143655 16994 487 0.0182318 0.0151730 0.0223352 NA NA NA NA NA NA NA
5494 143656 16995 487 0.0077657 0.0158941 0.0074965 NA NA NA NA NA NA NA
5495 143657 16996 487 0.0269572 0.1372526 0.0176499 NA NA NA NA NA NA NA
5496 143658 16997 487 0.0321413 0.2598237 0.0574108 NA NA NA NA NA NA NA
5497 143659 16998 487 0.0066798 0.0305333 0.0076761 NA NA NA NA NA NA NA
5498 143660 16999 487 0.0078665 0.0225598 0.0073810 NA NA NA NA NA NA NA
5499 143661 17000 487 0.0059451 0.0163147 0.0054411 NA NA NA NA NA NA NA
5500 143662 17001 487 0.0078065 0.0163793 0.0135396 NA NA NA NA NA NA NA

Mapping ViEWS data with Geo-PKO

To map the data, we’re going to use the leaflet package (and a bunch of others to support it). The first thing we do is set up our colour palette and bins. We’re using the ‘viridis’ colour palette, designed for accessibility and continuous-scale representation.

library(leaflet)
library(leaflet.providers)
library(htmltools)
library(htmlwidgets)

bins <- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
pal <- colorNumeric("viridis", NULL)

# small correction to spacing of NA in legend
css_fix <- "div.info.legend.leaflet-control br {clear: both;}" # CSS to correct spacing
html_fix <- htmltools::tags$style(type = "text/css", css_fix)  # Convert CSS to HTML

Next, let’s map. We include three colour layers to shade squares according to their conflict forecast value. These layers can be toggled between state-based conflict, non-state conflict, and one-sided violence. Troop deployment numbers are included as labels, which you can see for each square on hover. Labels for specific deployment locations also show the name of the location and country, on hover over location markers.

Zoom in for more detail.

map <- leaflet(shapefile.df) %>%
  addTiles() %>%
  addPolygons(
    color = "#444444", weight = 0.25, smoothFactor = 0.5,
    opacity = 0.05, fillOpacity = 0.4,
    fillColor = ~ pal(shapefile.df@data$average_allwthematic_sb),
    group = "State-Based Conflict"
  )  %>%
  addPolygons(
    color = "#444444", weight = 0.25, smoothFactor = 0.5,
    opacity = 0.05, fillOpacity = 0.4,
    fillColor = ~ pal(shapefile.df@data$average_allwthematic_ns),
    group = "Non-State Conflict"
  ) %>%
  addPolygons(
    color = "#444444", weight = 0.25, smoothFactor = 0.5,
    opacity = 0.05, fillOpacity = 0.4,
    fillColor = ~ pal(shapefile.df@data$average_allwthematic_os),
    group = "One-Sided Violence"
  ) %>%
  # these circle markers use geopko2 data to cover multiple locations per prioid
  addCircleMarkers(data = geopko2,
    lat = ~latitude, lng = ~longitude,
    weight = 1, radius = 2, fillOpacity = 0.6, color = "darkblue",
    group = "Deployment Locations",
    label = paste0(
      "<strong>Deployment Location: </strong>", geopko2$mission,
      "<br/><strong>Number of Troops: </strong>", geopko2$no.troops.yearly.avr,
      "<br/><strong>Location: </strong>", geopko2$location,", ", geopko2$country
    )
  %>%
  lapply(htmltools::HTML) 
  ) %>%
  addLegend("bottomright",
    pal = pal,
    values = shapefile.df$average_allwthematic_sb,
    title = "Conflict Forecast",
    opacity = 1
  ) %>%
  addLayersControl(
    baseGroups = c("State-Based Conflict", "Non-State Conflict", "One-Sided Violence"),
    overlayGroups = c("Deployment Locations"),
    options = layersControlOptions(collapsed = FALSE)
  ) %>% 
  htmlwidgets::prependContent(html_fix) # legend NA fix

map

And here we have it: an interactive map to view the latest peacekeeping data and projected conflict risk six months after the deployment period. You can zoom in to areas of higher conflict risk to see more detail, and mouse over deployment locations for more information. Note that some marked locations still say 0 for troop count; this indicates a mission site where no troops are deployed, but support personnel such as UNPOL or UNMO are present.

We can also do the same but with a world terrain basemap to identify, at a basic level, potential geographic impacts such as the greater concentration of conflict risk in mountainous areas, and the general deployment of peacekeepers in non-mountainous areas.

# adding provider tiles - replaces addTiles()
terrainmap <- map %>% addProviderTiles("Esri.WorldTerrain")

terrainmap

Extensions of this visualisation can be even more useful, particularly with a time-slider that can help us identify how the risk of conflict changes given peacekeeping deployments (and vice versa). This could be a valuable project for the future!

Geo-PKO x UCDP

Another useful dataset is from the Uppsala Conflict Data Programme, which offers insights into deaths from armed conflict. Looking at this data in conjunction with peacekeeping data can be useful to draw conclusions into peacekeeping given the severity of armed conflict, or lack thereof. We start by importing the “UCDP Georeferenced Event Dataset (GED) Global version 20.1”, of which a small excerpt of 2011 is shown in the table below.

UCDP <- read_csv("data/UCDP/ged201.csv")
kable(UCDP[9546:9550,]) %>% kable_styling() %>%
  scroll_box(width = "100%", height = "200px")
year longitude latitude where_coordinates best deaths_civilians
2019 68.23228 33.60806 Dara Qayaq river 2 0
2019 63.11753 31.91940 Rakin village 1 0
2019 65.87257 36.30936 Khanaqa village 7 0
2019 69.42800 37.41980 Qara Tapa village 17 0
2019 70.21723 33.46187 Babrak Tana ruin 6 6

Preparing the data

For the Geo-PKO data we only use certain variables, and calculate the average troop number by year. The UCDP data has different variables you could use. In this example we took best, which indicates “the best (most likely) estimate of total fatalities resulting from integer an event” and deaths_civilians, which tells us how many of this best variable were civilian deaths.

# Preparing the Geo-PKO dataset
GeoPKO_dataUCDP <- geopko %>%
  select(mission, year, location, latitude, longitude, no.troops) %>% # Select only the variables you need
  mutate_at(vars(latitude, longitude, no.troops), as.numeric) %>%
  group_by(mission, year, location) %>%
  mutate(ave.no.troops = as.integer(mean(no.troops, na.rm = TRUE))) %>% # Sum the troop numbers by year through using a combination of group_by & mutate
  select(-no.troops) %>% # Deselect the previous troop number variable
  distinct() %>% # Delete any duplicate rows
  drop_na(ave.no.troops) %>% # Remove NAs from the average troop count
  filter(ave.no.troops > 0) # Exclude any troop numbers under the value of 0

# Preparing the UCDP dataset
UCDP_dataframe <- UCDP %>%
  select(year, longitude, latitude, where_coordinates, best, deaths_civilians) %>%
  drop_na(latitude, longitude) %>%
  group_by(year, where_coordinates) %>%
  mutate(best = as.integer(mean(best, na.rm = TRUE))) %>% # Take the mean of the "best" variable
  mutate(deaths_civilians = as.integer(mean(deaths_civilians, na.rm = TRUE))) %>% # Take the mean of the "deaths_civilians" variable
  filter(best > 0 & year >= 1995) %>% # Filter that data so that it only keeps rows for the years after 1995.
  distinct()

Setting the aesthetics

You can either set all the colours by hand, as seen in pal3, or use the “viridis” package to create a colour scale for you, as shown in pal2. For the UCDP data we used shades of red. The Geo-PKO data is mapped with viridis, which includes blue, green, and yellow.

pal2 <- colorBin((viridis::viridis(10)), GeoPKO_dataUCDP$ave.no.troops, bins = c(1, 50, 100, 500, 1000, 2000, 4000, 8000))
pal3 <- colorBin(c("#700524", "#8d072e", "#981f42", "#ed4d3a", "#af516c", "#d19bab", "#dcb4c0"),
  UCDP_dataframe$best,
  bins = c(1, 50, 100, 500, 1000, 2000, 4000, 10000, Inf)
)

Mapping UCDP data with Geo-PKO

Just as we used leaflet for the ViEWS map, we do the same here. Note that in this case we did not merge the two datasets into one dataframe. When hovering over the circles, more information will be provided on either the UN peacekeeping deployment or on the UCDP conflict-related deaths. It is possible to use the PRIO-grid ID instead, and both datasets include this variable.

leaflet() %>%
  addTiles(options = providerTileOptions(noWrap = TRUE)) %>%
  addMeasure(position = "bottomleft", primaryLengthUnit = "kilometers") %>% # Adds a widget that can measure distances between two places to the map
  clearMarkers() %>%
  clearShapes() %>%
  addLegend("topright",
    pal = pal3,
    values = UCDP$best,
    title = "Fatalities",
    opacity = 1
  ) %>%
  addLegend("topright",
    pal = pal2,
    values = GeoPKO_dataUCDP$ave.no.troops,
    title = "Peacekeepers",
    opacity = 1
  ) %>%
  addLayersControl(
    baseGroups = c("2019", "2018", "2015", "2010", "2005", "2000", "1995"),
    options = layersControlOptions(collapsed = FALSE), position = "topleft"
  ) %>%
  addCircleMarkers(
    data = (GeoPKO2019 <- GeoPKO_dataUCDP %>% filter(year == 2019)),
    color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    opacity = 0.15, fillOpacity = 0.5,
    lng = ~longitude, lat = ~latitude, group = "2019",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2019$mission,
      "<br/><strong>Location:</strong>", GeoPKO2019$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO2019$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP2019 <- UCDP_dataframe %>% filter(year == 2019)),
    lng = ~longitude, lat = ~latitude,
    color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "2019",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2019$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP2019$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP2019$deaths_civilians
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (GeoPKO2018 <- GeoPKO_dataUCDP %>% filter(year == 2018)),
    color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    opacity = 0.15, fillOpacity = 0.5,
    lng = ~longitude, lat = ~latitude, group = "2018",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2018$mission,
      "<br/><strong>Location:</strong>", GeoPKO2018$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO2018$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP2018 <- UCDP_dataframe %>% filter(year == 2018)),
    lng = ~longitude, lat = ~latitude,
    color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "2018",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2018$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP2018$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP2018$deaths_civilians
    ) %>% lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (GeoPKO2015 <- GeoPKO_dataUCDP %>% filter(year == 2015)),
    color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    opacity = 0.15, fillOpacity = 0.5,
    lng = ~longitude, lat = ~latitude, group = "2015",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2015$mission,
      "<br/><strong>Location:</strong>", GeoPKO2015$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO2015$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP2015 <- UCDP_dataframe %>% filter(year == 2015)),
    lng = ~longitude, lat = ~latitude,
    color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "2015",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2015$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP2015$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP2015$deaths_civilians
    ) %>% lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (GeoPKO2010 <- GeoPKO_dataUCDP %>% filter(year == 2010)),
    color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    opacity = 0.15, fillOpacity = 0.5,
    lng = ~longitude, lat = ~latitude, group = "2010",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2010$mission,
      "<br/><strong>Location:</strong>", GeoPKO2010$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO2010$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP2010 <- UCDP_dataframe %>% filter(year == 2010)),
    lng = ~longitude, lat = ~latitude,
    color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "2010",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2010$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP2010$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP2010$deaths_civilians
    ) %>% lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (GeoPKO2005 <- GeoPKO_dataUCDP %>% filter(year == 2005)),
    color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    opacity = 0.15, fillOpacity = 0.5,
    lng = ~longitude, lat = ~latitude, group = "2005",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2005$mission,
      "<br/><strong>Location:</strong>", GeoPKO2005$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO2005$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP2005 <- UCDP_dataframe %>% filter(year == 2005)),
    lng = ~longitude, lat = ~latitude,
    color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "2005",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2005$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP2005$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP2005$deaths_civilians
    ) %>% lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (GeoPKO2000 <- GeoPKO_dataUCDP %>% filter(year == 2000)), color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    opacity = 0.15, fillOpacity = 0.5,
    lng = ~longitude, lat = ~latitude, group = "2000",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO2000$mission,
      "<br/><strong>Location:</strong>", GeoPKO2000$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO2000$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP2000 <- UCDP_dataframe %>% filter(year == 2000)),
    lng = ~longitude, lat = ~latitude,
    color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "2000",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP2000$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP2000$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP2000$deaths_civilians
    ) %>% lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (GeoPKO1995 <- GeoPKO_dataUCDP %>% filter(year == 1995)), color = ~ pal2(ave.no.troops), radius = ~ (ave.no.troops)^(1 / 3),
    lng = ~longitude, lat = ~latitude,
    opacity = 0.15, fillOpacity = 0.5,
    group = "1995",
    label = paste(
      "<strong>UN Peacekeeping Site<br/>Mission:</strong>", GeoPKO1995$mission,
      "<br/><strong>Location:</strong>", GeoPKO1995$location,
      "<br/><strong>Troops Deployed:</strong>", GeoPKO1995$ave.no.troops
    ) %>%
      lapply(htmltools::HTML)
  ) %>%
  addCircleMarkers(
    data = (UCDP1995 <- UCDP_dataframe %>% filter(year == 1995)),
    lng = ~longitude, lat = ~latitude, color = ~ pal3(best), radius = ~ (best)^(1 / 3),
    opacity = 0.05, fillOpacity = 0.4,
    group = "1995",
    label = paste(
      "<strong>UCDP Reported Fatalities<br/>Location:</strong>", UCDP1995$where_coordinates,
      "<br/><strong>Total deaths:</strong>", UCDP1995$best,
      "<br/><strong>Civilian deaths:</strong>", UCDP1995$deaths_civilians
    ) %>% lapply(htmltools::HTML)
  )
# to save as HTML, you can use the following code:
# saveWidget(UCDP_Overview_Map, file="geopko&ucdp - geopko.html")

And here we have it again: an interactive map to view peacekeeping deployments, in a few selected years, and conflict-related deaths within that same year. Select different years to see how both the numbers and locations of both datasets have changed over time.


sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_Sweden.1252  LC_CTYPE=English_Sweden.1252   
[3] LC_MONETARY=English_Sweden.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Sweden.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] htmlwidgets_1.5.1       htmltools_0.5.0         leaflet.providers_1.9.0
 [4] leaflet_2.0.3           geojsonio_0.9.2         rmapshaper_0.4.4       
 [7] RJSONIO_1.3-1.4         rjson_0.2.20            spdep_1.1-5            
[10] spData_0.3.8            ggplot2_3.3.2           sf_0.9-5               
[13] rgdal_1.5-16            sp_1.4-2                broom_0.7.0            
[16] tidyr_1.1.1             dplyr_1.0.2             kableExtra_1.1.0       
[19] readr_1.3.1             workflowr_1.6.2        

loaded via a namespace (and not attached):
 [1] nlme_3.1-148       fs_1.5.0           RColorBrewer_1.1-2 webshot_0.5.2     
 [5] gmodels_2.18.1     httr_1.4.2         rprojroot_1.3-2    tools_4.0.2       
 [9] backports_1.1.7    R6_2.4.1           KernSmooth_2.23-17 lazyeval_0.2.2    
[13] rgeos_0.5-3        DBI_1.1.0          colorspace_1.4-1   raster_3.3-13     
[17] withr_2.2.0        gridExtra_2.3      tidyselect_1.1.0   curl_4.3          
[21] compiler_4.0.2     git2r_0.27.1       cli_2.0.2          rvest_0.3.6       
[25] expm_0.999-5       xml2_1.3.2         scales_1.1.1       classInt_0.4-3    
[29] stringr_1.4.0      digest_0.6.25      foreign_0.8-80     rmarkdown_2.3     
[33] pkgconfig_2.0.3    highr_0.8          jsonvalidate_1.1.0 rlang_0.4.7       
[37] rstudioapi_0.11    httpcode_0.3.0     farver_2.0.3       generics_0.0.2    
[41] jsonlite_1.7.1     crosstalk_1.1.0.1  gtools_3.8.2       magrittr_1.5      
[45] Matrix_1.2-18      Rcpp_1.0.5         munsell_0.5.0      fansi_0.4.1       
[49] viridis_0.5.1      lifecycle_0.2.0    stringi_1.4.6      whisker_0.4       
[53] yaml_2.2.1         MASS_7.3-52        jqr_1.1.0          maptools_1.0-2    
[57] grid_4.0.2         gdata_2.18.0       promises_1.1.1     crayon_1.3.4      
[61] deldir_0.2-3       lattice_0.20-41    splines_4.0.2      geojson_0.3.4     
[65] hms_0.5.3          knitr_1.29         pillar_1.4.6       boot_1.3-25       
[69] geojsonlint_0.4.0  codetools_0.2-16   LearnBayes_2.15.1  crul_1.0.0        
[73] glue_1.4.1         evaluate_0.14      V8_3.2.0           vctrs_0.3.2       
[77] httpuv_1.5.4       gtable_0.3.0       purrr_0.3.4        assertthat_0.2.1  
[81] xfun_0.16          e1071_1.7-3        coda_0.19-4        later_1.1.0.1     
[85] class_7.3-17       viridisLite_0.3.0  tibble_3.0.3       units_0.6-7       
[89] ellipsis_0.3.1