Project Part 1

Preparing the Conflict and Terrorism Deaths for Plotting.

  1. I downloaded deaths from conflict and terrorism data from Our World in Data. I selected this data because I am interested in terrorism related deaths since 1990.

  2. This is the link to the data.

  3. The following code chunk loads the package that I will use to read in and prepare the data for analysis.

  1. Read the data in
deaths_from_conflict_and_terrorism <- 
  read_csv(here::here("_posts/2022-05-09-project-pt-1/deaths-from-conflict-and-terrorism.csv")) 
  1. Use glimpse to see the name and types of columns
glimpse(deaths_from_conflict_and_terrorism)
Rows: 6,840
Columns: 4
$ Entity                                                                 <chr> …
$ Code                                                                   <chr> …
$ Year                                                                   <dbl> …
$ `Deaths - Conflict and terrorism - Sex: Both - Age: All Ages (Number)` <dbl> …
  1. Use output from glimpse to prepare the data for analysis
deaths  <- c("India",
             "United States",
             "Russia",
             "United Kingdom",
             "France",
             "Germany",
             "Japan",
             "China")

conflict_deaths  <- deaths_from_conflict_and_terrorism  %>%
  rename(Region = 1, Deaths = 4)  %>%
  filter(Year >= 1990, Deaths %in% Deaths)  %>%
  select(Region, Year, Deaths)  %>%
  mutate(Deaths = Deaths * 1e-3)

conflict_deaths
# A tibble: 6,840 × 3
   Region       Year Deaths
   <chr>       <dbl>  <dbl>
 1 Afghanistan  1990   1.49
 2 Afghanistan  1991   3.37
 3 Afghanistan  1992   4.34
 4 Afghanistan  1993   4.10
 5 Afghanistan  1994   8.96
 6 Afghanistan  1995   5.52
 7 Afghanistan  1996   3.26
 8 Afghanistan  1997   6.72
 9 Afghanistan  1998  12.1 
10 Afghanistan  1999   5.10
# … with 6,830 more rows

Check that the total for 2019 equals the total in the graph

conflict_deaths  %>% filter(Year == 2019)  %>%
  summarise(total_deaths = sum(Deaths))
# A tibble: 1 × 1
  total_deaths
         <dbl>
1         316.

Add a picture

See how to change the width in the R Markdown Cookbook

Regional conflict and terrorism deaths

Write the data to file in the project directory

write_csv(conflict_deaths, file = "deaths_from_conflict_and_terrorism")