library(stringr)

# Get the current page number from the file name
current_page <- as.numeric(str_extract(knitr::current_input(), "\\d+"))

# Set the total number of pages
total_pages <- 9

# Generate the URLs for the previous and next pages
previous_page <- ifelse(current_page > 1, paste0("visual_", current_page - 1, "-darfur_violence-code_included.html"), NA)
next_page <- ifelse(current_page < total_pages, paste0("visual_", current_page + 1, "-darfur_violence-code_included.html"), NA)


In June 2017, the UN Security Council adopted Resolution 2363 (2017) in which it decided to close down bases starting that same year, in multiple phases. The goal was set to end the mission within 2 years.


# Note: All code, insights shared, and methodological notes in this document and other documents in this portfolio ARE NOT open source and MUST be cited.

library(tidyverse)
library(ggplot2)
library(ggthemes)
library(ggimage)


setwd("C:/Users/rsb84/Desktop/RB/COLUMBIA/QMSS/COURSES/Spring_2021/Data Visualization/End_project/")

ACLED_data <- readxl::read_excel("ACLED-DARFUR-VAC-2008-2021 (After Course Ended-for 2023 Portfolio).xlsx", col_types = c("date", "numeric", "text", 
         "text", "text", "text", "text", "text", 
         "text", "text", "text", "text", "text", 
         "numeric", "numeric", "text", "text", 
         "numeric", "numeric"))

fatalities_by_year=ACLED_data %>% group_by(year) %>% tally(fatalities)

ak47_icon = "C:/Users/rsb84/Desktop/RB/COLUMBIA/QMSS/COURSES/Spring_2021/Data Visualization/End_project/ak-47_5_thumbnail.png"

fatalities_by_year$image = c(ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon, ak47_icon)


visual_2 <- ggplot(fatalities_by_year, aes(x=fatalities_by_year$year, y=fatalities_by_year$n, fill=as.character(year))) + geom_vline(xintercept=as.integer(2017), color = "green4", linetype="dashed", size = 1) + geom_vline(xintercept=as.integer(2019), color = "purple",linetype="dashed", size = 1) + geom_bar(stat="identity", width=0.45) + scale_fill_manual("legend", values = c("2008" = "gray75", "2009" = "gray75", "2010" = "gray75", "2011" = "gray75", "2012" = "gray75", "2013" = "gray75", "2014" = "gray75", "2015" = "gray75", "2016" = "gray75", "2017" = "deepskyblue1", "2018" = "deepskyblue1", "2019" = "deepskyblue1", "2020" = "deepskyblue1", "2021" = "deepskyblue1")) + geom_text(aes(label=n), vjust=1.5, color="red", size=3.2) + geom_image(image=fatalities_by_year$image, size=0.09, nudge_x=-.05, nudge_y=15) +  scale_x_continuous("Year of Mission") + scale_y_continuous("Civilian Killings") + theme_wsj() + theme(title =element_text(size=13, color= "steelblue", face='bold'), axis.title.x=element_blank(), axis.title.y=element_blank(), axis.text.x = element_text(size = 9.7), axis.text.y = element_text(size = 12), legend.position="none") + labs(title="Civilian Killings During Years UNAMID Troops Were Present", subtitle="", caption = "Source: The Armed Conflict Location & Event Data Project dataset, dates: Jan. 2008-Dec. 2021") + annotate("text", x= as.numeric(2015.8), y= as.numeric(700), label="The First Year\n UN Bases Began\nClosing", fontface=2, size=3, color="green4") + annotate("text", x= as.numeric(2020.5), y= as.numeric(685), label="The Year the Security\n Council Decided to\n Completely Withdraw\nUNAMID", fontface=2, size=3, color="purple")
visual_2


Retrospectively, we also see that between the end of 2020 and the end of 2021 there was a 75% increase in civilian killings.


# Get the current page number from the file name
current_page <- as.numeric(str_extract(knitr::current_input(), "\\d+"))

# Set the total number of pages
total_pages <- 9

# Generate the URLs for the previous and next pages
previous_page <- ifelse(current_page > 1, paste0("visual_", current_page - 1, "-darfur_violence-code_included.html"), NA)
next_page <- ifelse(current_page < total_pages, paste0("visual_", current_page + 1, "-darfur_violence-code_included.html"), NA)