The data set can be downloaded here. Dataset consists of the global attacks that has been accepted as ‘terrorist attack’ with lots of variables. This research aims to demonstrate the terrorist attacks situation took place in Turkey, 2016.

library("tidyverse")
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag():    dplyr, stats
globaldata<-read.csv(file="globalterrorismdb_0617dist.csv", header=TRUE)
turkeydata<-globaldata%>%
  filter(country_txt=="Turkey")%>%
  group_by(iyear,provstate,imonth,success,gname,targtype1_txt)%>%
  summarise(number_of_attacks=n())
ggplot(turkeydata, aes(x=iyear,y=number_of_attacks)) + geom_bar(stat = "identity")

globaldata16 <-globaldata%>%
  filter(iyear=="2016") %>% 
  group_by(country_txt) %>% 
  summarise(number_of_attacks=n())%>%
  filter(number_of_attacks>100)%>%
  arrange(desc(number_of_attacks))%>%
  mutate(isTurkey=(country_txt == "Turkey"))
ggplot(globaldata16, aes(x=country_txt,y=number_of_attacks)) +
  geom_point(aes(color=isTurkey))+
  theme(axis.text.x=element_text(angle=45,hjust=1,vjust=1))

turkeydata16_sehirleregore<-turkeydata%>%
  filter(iyear=="2016",success=="1")%>%
  group_by(provstate)%>%
  summarise(number_of_attacks=n())
ggplot(turkeydata16_sehirleregore, aes(x=provstate,y=number_of_attacks)) +
  geom_bar(stat = "identity")+
  theme(axis.text.x=element_text(angle=45,hjust=1,vjust=1))

turkeydata16_basariorani<-turkeydata%>%
  filter(iyear=="2016")%>%
  group_by(gname)%>%
  summarise(number_of_attacks=n(),basarililar=sum(success))%>%
  mutate(basariyuzdesi=(basarililar/number_of_attacks)*100)
ggplot(turkeydata16_basariorani, aes(x=gname,y=basariyuzdesi)) + 
  geom_bar(stat = "identity")+
  theme(axis.text.x=element_text(angle=45,hjust=1,vjust=1))

#orgutler
turkeydata16_orgutler<-turkeydata%>%
  filter(iyear=="2016",success=="1")%>%
  group_by(gname)%>%
  summarise(number_of_attacks=n())
ggplot(turkeydata16_orgutler, aes(x=gname,y=number_of_attacks)) + 
  geom_bar(stat = "identity")+
  theme(axis.text.x=element_text(angle=45,hjust=1,vjust=1))

#hedef
turkeydata16_hedef<-turkeydata%>%
  filter(iyear=="2016",success=="1")%>%
  group_by(targtype1_txt)%>%
  summarise(number_of_attacks=n())
ggplot(turkeydata16_hedef, aes(x=targtype1_txt,y=number_of_attacks)) + 
  geom_bar(stat = "identity")+
  theme(axis.text.x=element_text(angle=45,hjust=1,vjust=1))