Skip to content

Instantly share code, notes, and snippets.

@daattali
Created October 5, 2013 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daattali/6847430 to your computer and use it in GitHub Desktop.
Save daattali/6847430 to your computer and use it in GitHub Desktop.
```{r include = FALSE}
opts_chunk$set(tidy = FALSE)
```
Terrorism in Israel
===========================
**Dean Attali**
**Oct 4, 2013**
**STAT 545A**
Overview
----------------
Here I used the international terrorist database (available [here](http://www.start.umd.edu/gtd/)) to look into some statistics about terrorism in Israel, and mainly suicide bombings. While this database has many interesting stories in it , I chose to just focus on the ones that affected me. This data is interesting to me because I grew up in Tel Aviv and would always hear about bombings or other terrorist activity nearby.
Around the beginning of 2001, what is called the "second intifada" started, and that period of violence can be clearly seen in the plots as large spikes in bombing activity. Since the situation got a little scary, my parents decided to leave the country and move to Canada in 2002.
Initialization
-----------------
```{r}
# read input
dat <- read.csv("globalterrorismdb.csv", header = TRUE, na.strings = c("", "."))
dim(dat)
```
```{r results='hide', message=FALSE, warning=FALSE}
# load libraries
library(ggplot2)
library(plyr) # for ddply
library(ggthemes) # for use of premade themes
library(reshape) # for melt
```
```{r}
# only keep rows corresponding to data in Israel
israel <- subset(dat, country_txt == 'Israel')
```
Frequency of attack type
-------------------------
First I want to look at the frequency of each type of terrorist attack. We will use a pie chart to visualize this.
```{r fig.height=4, fig.width=10}
# reorder the levels of attacktype according to which attack type was most frequent
# (doing this so that the legend in the following pie chart will be in order)
attackTypeOrder = order(table(israel$attacktype1_txt), decreasing = TRUE)
attackTypeLevels = names(table(israel$attacktype1_txt))[attackTypeOrder]
israel$attacktype1_txt <- factor(israel$attacktype1_txt, levels = attackTypeLevels)
ggplot(israel, aes(x = "", fill = attacktype1_txt)) +
geom_bar(width = 1) +
coord_polar(theta = "y") +
scale_fill_brewer("Attack Type", type = "qual", palette = 6) +
ggtitle("Terrorist attacks in Israel since 1970") +
theme(panel.grid = element_blank(),
axis.text = element_blank(), axis.ticks = element_blank(),
axis.title = element_blank(), panel.background = element_blank())
```
We can see bombings are by far the #1 most common attack, with armed assault and assassinations as the only significant runner ups.
Casualties per attack type
------------------
Another important piece of information to look at is which attacks resulted in the most casualties.
```{r fig.height=5, fig.width=10}
# We can use plyr to compute the number of people killed/injured each year per attack type
attackDamage <- ddply(israel, ~iyear + attacktype1_txt,
summarize,
killed = sum(nkill, na.rm = TRUE),
wounded = sum(nwound, na.rm = TRUE))
ggplot(attackDamage, aes(x = iyear, y = killed, fill = attacktype1_txt)) +
geom_bar(stat = "identity") +
scale_fill_brewer("Attack Type", type = "qual", palette = 6) +
ggtitle("Deaths in Israel by attack type") + xlab("Year") + ylab("Number killed")
```
We can see that bombings indeed killed the most people over the years (although it seems like there were a few big deadly hostage situations in the 70's). The onstart of the intifada in the early 2000's is esily seen in this plot, in the columns representing bombings and assaults.
People wounded/killed by suicide bombings
-----------------------------
Since suicide bombing is the most prominent terrorist attack in Israel with the most casualties from it, I want to see how many people got wounded and killed from such bombings.
```{r fig.height=5, fig.width=10}
bombingDamage <- subset(attackDamage, attacktype1_txt == 'Bombing/Explosion')
# we use melt to reshape the data, easier to plot it and get a legend without any extra work
bombingDamage <- melt(data = bombingDamage, id.vars = c('iyear', 'attacktype1_txt'))
ggplot(bombingDamage, aes(x = iyear, y = value, color = variable)) +
geom_line() +
scale_x_continuous(name = "Year", breaks = seq(min(israel$iyear), max(israel$iyear), by = 5)) +
ggtitle("Deaths and wounded by suicide bombings in Israel") +
ylab("Number of people") +
scale_color_manual("Injury Type", values = c("black", "red")) +
guides(color = guide_legend(reverse = TRUE)) +
geom_point()
```
This plot revelas again the escalation in bombings in the early 2000's, just before my dad decided to leave.
Number of suicide bombings in my city while I was there
---------------------------
The last thing I want to look at is how many bombings happened in the city where I grew up, while I was growing up there. I make a bar graph for this, comparing bombings in Tel Aviv vs the rest of Israel each year since my birth until my arrival to Canada.
```{r fig.height=5, fig.width=10}
# add a column indicating whether a bombing event happened in TA or in the rest of the country
israelBombings <- subset(israel, attacktype1 == 3)
israelBombings <- droplevels(israelBombings)
myYearsBombings <- subset(israelBombings, iyear %in% seq(1988,2002))
myYearsBombings <- myYearsBombings[,c('iyear','city')]
myYearsBombings <- droplevels(myYearsBombings)
myYearsBombings$inTA <- ifelse(myYearsBombings$city == 'Tel Aviv', 'Tel Aviv', 'Rest of Israel')
ggplot(myYearsBombings, aes(x = iyear, fill = inTA)) +
geom_bar(binwidth = 1, color = "darkgrey", origin = min(myYearsBombings$iyear) - 0.5, position = "identity") +
scale_x_continuous(name = "Year", breaks = seq(1988, 2002, by = 1)) +
theme_solarized() +
theme(axis.text.x = element_text(angle = 90)) +
scale_fill_brewer("Location", type = "qual", palette = 3) +
ylab("Number of bombings") +
ggtitle("Sucide bombings in Israel between 1988-2002")
```
It looks like out of almost 100 bombings in 2001-2002, over 10 of them were in Tel Aviv.
_Just as a side note, 1993 was NOT some magical year of peace. All data from 1993 was lost and not recovered by the providers of this dataset_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment