-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject_Data_Science.Rmd
More file actions
731 lines (573 loc) · 23.4 KB
/
Project_Data_Science.Rmd
File metadata and controls
731 lines (573 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
---
title: 'Project: Data Science'
author: "Sean E. Curl & Steven Aguilar"
date: "April 25, 2018"
output:
pdf_document: default
html_document: default
word_document: default
---
```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(readxl)
library(readr)
library(tidyverse)
library(styler)
library(purrr)
library(ggthemes)
library(ggmap)
library(ggplot2)
library(ggthemes)
library(purrr)
library(ggrepel)
library(revealjs)
```
## About
> - Global Terrorism Database (GTD)
> - Study of Terrorism and Responses to Terrorism (START)
> - University of Maryland
https://www.kaggle.com/START-UMD/gtd
Global Terrorism Database (GTD) is an open-source database with information about terrorist attacks worldwide from 1970 to 2016. The database is maintained by researchers at the National Consortium for the Study of Terrorism and Responses to Terrorism (START), headquartered at the University of Maryland.
#### Definition of terrorism:
> - "The threatened or actual use of illegal force and violence by a non-state actor to attain a political, economic, religious, or social goal through fear, coercion, or intimidation."
#### Observations
> - The data-set included 170,350 observations.
#### Variables?
> - Great than 100 variables on location, tactics, perpetrators, targets, and outcomes.
See the http://start.umd.edu/gtd/downloads/Codebook.pdf for important details on data collection methodology, definitions, and coding schema.
The Global Terrorism Database is funded through START, by the US Department of State and the US Department of Homeland Security Science and Technology Directorate's Office of University Programs. The coding decisions and classifications contained in the database are determined independently by START researchers and should not be interpreted as necessarily representing the official views or policies of the United States Government.
## Load and Clean
```{r echo=FALSE, message=FALSE, warning=FALSE}
terrorism <- read_xlsx(path = "./globalterrorismdb_0617dist.xlsx", col_types = "text") %>%
select("Year" = iyear,
"Month" = imonth,
"Day" = iday,
"Country" = country_txt,
"Region" = region_txt,
"AttackType" = attacktype1_txt,
"Target" = target1,
"Killed" = nkill,
"Wounded" = nwound,
"Summary" = summary,
"Group" = gname,
"Target_Type" = targtype1_txt,
"Weapon_type" = weapsubtype1_txt,
"Motive" = motive,
"City" = city,
"lat" = latitude,
"long" = longitude,
"City" = city) %>%
mutate(Killed = as.numeric(Killed),
Wounded = as.numeric(Wounded), lat = as.numeric(lat), long = as.numeric(long)) %>%
mutate(Casualties = Killed + Wounded) %>%
glimpse()
terrorism %>%
map_dbl(~sum(is.na(.)))
```
In the interested of time and sanity, we selected from the >100 variables, the best variables we thought would lead to a 'quick n' easy' interpretable user experience. As a result, we also created a variable of our own called 'causalities.' The variable is the summation of the Killed and Wounded variables. This variable allowed us a quick and easy way measure the impact a particular terrorist event(s) by using only a single variable.
As you can see, the terrorism database has a bunch of missing observations amongst Target, Killed, Wounded, Summary, Weapon_type, Motive, City, lat, long, and Casualties. Many of these variables are missing simply because the researchers lacked the fidelity for an exact location, weapon, motive, etc. In the case of Killed and Wounded, missing values represent that fact that no person was either killed or wounded in that particular attack. For example, an attack could be deemed a success if the intended target was destroyed (e.g. infrastructure), but there might not have been any casualties as a result of the attack.
## High Impact Areas
```{r echo=FALSE, message=FALSE, warning=FALSE}
Year_highest_attacks <- terrorism %>%
group_by(Year) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
slice(1)
Month_highest_attacks <- terrorism %>%
group_by(Month) %>%
summarise(n = mean(n())) %>%
arrange(desc(n)) %>%
slice(1)
Day_highest_attacks <- terrorism %>%
group_by(Day) %>%
summarise(n = mean(n())) %>%
arrange(desc(n)) %>%
slice(1)
country_highest_attacks <- terrorism %>%
group_by(Country) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
slice(1)
region_highest_attacks <- terrorism %>%
group_by(Region) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
slice(1)
AttackType_highest <- terrorism %>%
group_by(AttackType) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
slice(1)
Target_highest <- terrorism %>%
group_by(Target) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
slice(1)
highest_killed <- terrorism %>%
group_by(Year, Country, Killed) %>%
summarise(max(Killed)) %>%
arrange(desc(Killed)) %>%
head(1)
highest_wounded <- terrorism %>%
group_by(Year, Country, Wounded) %>%
summarise(max(Wounded)) %>%
arrange(desc(Wounded)) %>%
head(1)
Group_highest <- terrorism %>%
filter(!Group == "Unknown") %>%
group_by(Group) %>%
summarise(n = n()) %>%
arrange(desc(n)) %>%
slice(1)
paste("Year with Highest Terrorist Attacks:", Year_highest_attacks$Year)
paste("Month with Highest Terrorist Attacks:", Month_highest_attacks$Month)
paste("Day with Highest Terrorist Attacks:", Day_highest_attacks$Day)
paste("Country with Highest Terrorist Attacks:", country_highest_attacks$Country)
paste("Region with Highest Terrorist Attacks:", region_highest_attacks$Region)
paste("AttackType with Highest Terrorist Attacks:", AttackType_highest$AttackType)
paste("Target with Highest Terrorist Attacks:", Target_highest$Target)
paste("Maximum peopled killed in an attack are:", "In", highest_killed$Year, highest_killed$`max(Killed)`, "peopled died in",highest_killed$Country)
paste("Maximum peopled wounded in an attack are:", "In", highest_wounded$Year, highest_wounded$`max(Wounded)`, "peopled died in",highest_wounded$Country)
paste("Group with Highest Terrorist Attacks (not unk.):", Group_highest$Group)
```
## Popular Attack Types
```{r echo=FALSE, message=FALSE, warning=FALSE}
attacking_methods <- terrorism %>%
group_by(AttackType) %>%
summarise(n = n()) %>%
arrange(n) %>%
ggplot(mapping = aes(reorder(AttackType, n), n, fill = AttackType)) +
geom_bar(stat = "identity", show.legend = FALSE) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size = 10)) +
ylab("Count") +
xlab("Attack Type") +
ggtitle("Attack Methods Used") +
theme_set(theme_bw()) +
labs(subtitle = "1970 - 2016", caption = "Source: GTD") +
coord_flip()
attacking_methods
```
#### Here's a table view. . .
```{r echo=FALSE, message=FALSE, warning=FALSE}
attacking_methods_table <- terrorism %>%
group_by(AttackType) %>%
summarise(n = n()) %>%
arrange(desc(n))
print(attacking_methods_table)
```
#### Let's take a look at the top three attack types. I'll include Year, Group, and Country too.
```{r echo=FALSE, message=FALSE, warning=FALSE}
attacking_methods_table <- terrorism %>%
filter(!Group == "Unknown") %>%
group_by(AttackType, Year, Country, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n)) %>%
head(1)
attacking_methods_table2 <- terrorism %>%
filter(AttackType == "Armed Assault") %>%
group_by(AttackType, Year, Country, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n)) %>%
head(1)
attacking_methods_table3 <- terrorism %>%
filter(AttackType == "Assassination") %>%
group_by(AttackType, Year, Country, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n)) %>%
head(1)
union1 <- union(attacking_methods_table, attacking_methods_table2)
union2 <- union(union1, attacking_methods_table3)
union2
```
## Number of Terrorist Acivities Year
```{r echo=FALSE, message=FALSE, warning=FALSE}
# Number of Terrorist Acivities Year
count <- terrorism %>%
group_by(Year) %>%
summarise(n = n()) %>%
mutate(Year = as.numeric(Year))
ggplot(count,
aes(x = Year,
y = n, fill = factor(Year))) +
geom_bar(stat = "identity", show.legend = FALSE) +
xlab("Year") +
ylab("Count") +
ggtitle("Global Number of Terrorist Acivities") +
scale_x_continuous(breaks = c(1970, 1980, 1990, 2000, 2010, 2020), limits = c(1970, 2016)) +
theme_set(theme_bw()) +
labs(subtitle = "1970 - 2016",
caption = "Source: GTD") +
coord_flip()
```
#### We can see that the most recent years had a significant increase in violence.
```{r echo=FALSE, message=FALSE, warning=FALSE}
# Number of Terrorist Acivities, Top Six Years
count2 <- terrorism %>%
group_by(Year) %>%
summarise(n = n()) %>%
arrange(desc(n))
print(head(count2))
```
#### Let's take a look at the Year's > 2010.
```{r echo=FALSE, message=FALSE, warning=FALSE}
Year_Great_2010 <- terrorism %>%
filter(!Group == "Unknown") %>%
filter(Year >= '2010' & Year <= '2016') %>%
group_by(Year, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n))
output1 <- distinct(Year_Great_2010, Country, .keep_all = TRUE)
head(output1, 5)
```
#### How about looking at the Year's < 2010?
```{r echo=FALSE, message=FALSE, warning=FALSE}
Year_Less_2010 <- terrorism %>%
filter(!Group == "Unknown") %>%
filter(Year < '2010') %>%
group_by(Year, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n))
output <- distinct(Year_Less_2010, Year, .keep_all = TRUE)
head(output, 5)
```
## Terrorist Targets by Count
```{r echo=FALSE, message=FALSE, warning=FALSE}
count <- terrorism %>%
group_by(Target_Type) %>%
summarise(n = n()) %>%
head(10)
ggplot(count,
aes(reorder(x = Target_Type, n),
y = n, fill = factor(Target_Type))) +
geom_bar(stat = "identity", show.legend = FALSE) +
xlab("Target Type") +
ylab("Count") +
ggtitle("Global Terrorist Targets") +
theme(axis.text.x=element_text(angle = 90, hjust =1)) +
theme_set(theme_bw()) +
labs(subtitle = "by Count",
caption = "Source: GTD") +
coord_flip()
```
#### What are the top 5 preferred targets for different groups?
```{r echo=FALSE, message=FALSE, warning=FALSE}
Target_Group <- terrorism %>%
filter(!Group == "Unknown") %>%
group_by(Target_Type, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n))
output <- distinct(Target_Group, Target_Type, .keep_all = TRUE)
head(output, 5)
```
#### What are top 5 preferred targets within different countries?
```{r echo=FALSE, message=FALSE, warning=FALSE}
Target_Country <- terrorism %>%
group_by(Target_Type, Country) %>%
summarise(n = max(n())) %>%
arrange(desc(n))
output <- distinct(Target_Country, Target_Type, .keep_all = TRUE)
head(output, 5)
```
## Terrorist Attacks by Region
```{r echo=FALSE, message=FALSE, warning=FALSE}
count <- terrorism %>%
group_by(Region) %>%
summarise(n = n())
ggplot(count,
aes(reorder(x = Region, n),
y = n, fill = factor(Region))) +
geom_bar(stat = "identity", show.legend = FALSE) +
xlab("Region") +
ylab("Count") +
ggtitle("Global Terrorist Attacks") +
theme(axis.text.x=element_text(angle = 90, hjust =1)) +
theme_set(theme_bw()) +
labs(subtitle = "by Geographic Region",
caption = "Source: GTD") +
coord_flip()
```
#### It's important to look across a timeframe. Let's compare Region across the years.
```{r echo=FALSE, message=FALSE, warning=FALSE}
Attack.region.count <- terrorism %>%
group_by(Region, Year) %>%
summarise(total = sum(n())) %>%
mutate(Year = as.numeric(Year))
ggplot(Attack.region.count,
aes(x = Year,
y = total, colour = Region, group = Region)) +
geom_line(stat = "identity", lwd = 1) +
xlab("Year") +
ylab("Count") +
ggtitle("Terrorist Attacks") +
scale_x_continuous(breaks = c(1970, 1980, 1990, 2000, 2010, 2020), limits = c(1970, 2016)) +
theme_set(theme_bw()) +
labs(subtitle = "by Region",
caption = "Source: GTD")
```
#### Which regions have the highest amount of terrorist events?
```{r echo=FALSE, message=FALSE, warning=FALSE}
Target_Region <- terrorism %>%
group_by(Year, Region) %>%
summarise(n = max(n())) %>%
arrange(desc(n))
output <- distinct(Target_Region, Year, .keep_all = TRUE)
head(output, 10)
```
#### ...which regions have which groups? Here's the top 6.
```{r echo=FALSE, message=FALSE, warning=FALSE}
Target_Region_Group <- terrorism %>%
filter(!Group == "Unknown") %>%
group_by(Region, Group) %>%
summarise(n = max(n())) %>%
arrange(desc(n))
output <- distinct(Target_Region_Group, Region, .keep_all = TRUE)
head(output, 6)
```
## Terrorist attacks by Group. We'll show the top 10.
```{r echo=FALSE, message=FALSE, warning=FALSE}
count <- terrorism %>%
filter(!Group == "Unknown" & Group %in% c("Taliban", "Shining Path (SL)",
"Islamic State of Iraq and the Levant (ISIL)", "Farabundo Marti National Liberation Front (FMLN)", "Al-Shabaab",
"Irish Republican Army (IRA)",
"Revolutionary Armed Forces of Colombia (FARC)",
"New People's Army (NPA)",
"Kurdistan Workers' Party (PKK)",
"Boko Haram")) %>%
group_by(Group, Year) %>%
summarise(total = n()) %>%
mutate(Year = as.numeric(Year))
ggplot(count,
aes(x = Year,
y = total, colour = Group, group = Group)) +
geom_line(stat = "identity", lwd = 1) +
xlab("Year") +
ylab("Count") +
scale_x_continuous(breaks = c(1970, 1980, 1990, 2000, 2010, 2020), limits = c(1970, 2016)) +
ggtitle("Terrorist Attacks") +
theme(legend.title = element_text(color = "black", size = 10, face = "bold")) +
theme_set(theme_bw()) +
labs(subtitle = "by Group",
caption = "Source: GTD")
```
## Global Maps Plots: Total Terrorism Attacks from 1970 - 2016
```{r echo=FALSE, message=FALSE, warning=FALSE, cache=FALSE}
GTA_graph_data <- terrorism %>%
group_by(Country, long, lat, Casualties) %>%
summarise(total = sum(Casualties))
```
```{r echo=FALSE, message=FALSE, warning=FALSE}
mp <- NULL
mapWorld <- borders("world", colour="gray50", fill="gray50")
mp <- ggplot() + mapWorld +
geom_point(data = GTA_graph_data, mapping = aes(x=long, y=lat,
group = Country, size = total, color = "red"),
show.legend = FALSE) +
theme_bw() +
theme(axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.line = element_blank()) +
ggtitle(paste("Global Terror Attacks"))
mp + coord_map(xlim = c(-180, 180)) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) +
labs(subtitle = "1970 - 2016", caption = "Source: GTD")
```
## Global Maps Plots: Terrorism by Groups from 1970 - 2016
```{r echo=FALSE, message=FALSE, warning=FALSE}
test <- terrorism %>%
filter(!Group == "Unknown") %>%
group_by(Group) %>%
summarise(total = n()) %>%
arrange(desc(total)) %>%
slice(1:10)
graph_data1 <- terrorism %>%
filter(!Group == "Unknown" & Group %in% c("Taliban", "Shining Path (SL)",
"Islamic State of Iraq and the Levant (ISIL)", "Farabundo Marti National Liberation Front (FMLN)", "Al-Shabaab",
"Irish Republican Army (IRA)",
"Revolutionary Armed Forces of Colombia (FARC)",
"New People's Army (NPA)",
"Kurdistan Workers' Party (PKK)",
"Boko Haram")) %>%
group_by(Group, long, lat) %>%
summarise(total = n()) %>%
arrange(desc(total))
lp <- NULL
mapWorld <- borders("world", colour="gray50", fill="gray50")
lp <- ggplot(data = graph_data1, mapping = aes(x=long, y=lat)) + mapWorld +
geom_point(aes(color = Group)) +
theme_bw() +
theme(axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.line = element_blank()) +
ggtitle("Global Events") +
theme(legend.title = element_text(color = "black", size = 10, face = "bold")) +
guides(color = guide_legend(override.aes = list(size = 1))) +
labs(subtitle = "by the Top 10 Terrorist Organizations since 1970",
caption = "Source: GTD")
lp + coord_map(xlim = c(-180, 180)) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
```
## Terrorist Attacks by City within USA
```{r echo=FALSE, message=FALSE, warning=FALSE}
highest_USA <- terrorism %>%
filter(City %in% c("New York City", "Oklahoma City",
"The Dalles",
"Arlington",
"West",
"Boston",
"Atlanta",
"Orlando")) %>%
group_by(City) %>%
summarise(total = sum(n())) %>%
arrange(desc(total))
ggplot(highest_USA,
aes(reorder(x = City, total),
y = total, fill = factor(City))) +
geom_bar(stat = "identity", width = .5, fill = "red", show.legend = FALSE) +
xlab("City Name") +
ylab("Count") +
ggtitle("Highest Number of U.S. City Terrorist Attacks") +
labs(subtitle = "with New York City",
caption = "Source: GTD") +
theme_set(theme_bw()) +
theme(axis.text.x = element_text(vjust=0.6)) +
coord_flip()
```
#### New York City has the highest number of terrorist attacks since 1970.
```{r echo=FALSE, message=FALSE, warning=FALSE}
count <- terrorism %>%
filter(City == "New York City") %>%
group_by(City, Year) %>%
summarise(total = sum(n())) %>%
arrange(desc(total))
output <- distinct(count, Year, .keep_all = TRUE)
head(output, 10)
```
#### What do these attacks look like across time?
```{r echo=FALSE, message=FALSE, warning=FALSE}
highest_USA <- terrorism %>%
filter(City %in% c("New York City", "Oklahoma City",
"The Dalles",
"Arlington",
"West",
"Boston",
"Atlanta",
"Orlando")) %>%
group_by(City, Year) %>%
summarise(total = sum(n())) %>%
arrange(desc(total)) %>%
mutate(Year = as.numeric(Year))
ggplot(highest_USA,
aes(x = Year,
y = total, colour = City, group = City)) +
geom_line(stat = "identity", lwd = 1) +
xlab("Year") +
ylab("Count") +
scale_x_continuous(breaks = c(1970, 1980, 1990, 2000, 2010, 2020), limits = c(1970, 2016)) +
ggtitle("U.S. City Terrorist Attacks") +
theme(legend.title = element_text(color = "black", size = 10, face = "bold")) +
theme_set(theme_bw()) +
labs(subtitle = "by City",
caption = "Source: GTD")
```
#### Across all U.S. cities, which had the deadliest attacks?
```{r echo=FALSE, message=FALSE, warning=FALSE}
highest_killed_USA <- terrorism %>%
filter(Country == "United States") %>%
group_by(Year, City, Casualties) %>%
summarise(total = sum(Casualties)) %>%
arrange(desc(total))
output <- distinct(highest_killed_USA, City, .keep_all = TRUE)
head(output, 10)
```
#### Let's exclude New York City.
```{r echo=FALSE, message=FALSE, warning=FALSE}
count <- terrorism %>%
filter(City %in% c("Oklahoma City", "Hyder", "Shanksville",
"The Dalles",
"Arlington",
"West",
"Boston",
"Atlanta",
"Orlando")) %>%
group_by(City) %>%
summarise(total = sum(n())) %>%
arrange(desc(total))
ggplot(count,
aes(reorder(x = City, total),
y = total, fill = factor(City))) +
geom_bar(stat = "identity", width = .5, fill = "red", show.legend = FALSE) +
xlab("City Name") +
ylab("Count") +
ggtitle("Terrorist Attacks in Top U.S. Cities") +
theme_set(theme_bw()) +
labs(subtitle = "Minus New York City",
caption = "Source: GTD") +
coord_flip()
```
```{r echo=FALSE, message=FALSE, warning=FALSE}
count <- terrorism %>%
filter(City %in% c("Oklahoma City",
"The Dalles",
"Arlington",
"West",
"Boston",
"Atlanta",
"Orlando")) %>%
group_by(City, Year) %>%
summarise(total = sum(n())) %>%
arrange(desc(total))
output <- distinct(count, City, .keep_all = TRUE)
head(output)
```
#### Again, what do these attacks look like across time?
```{r echo=FALSE, message=FALSE, warning=FALSE}
highest_USA <- terrorism %>%
filter(City %in% c("Oklahoma City",
"The Dalles",
"Arlington",
"West",
"Boston",
"Atlanta",
"Orlando")) %>%
group_by(City, Year) %>%
summarise(total = sum(n())) %>%
arrange(desc(total)) %>%
mutate(Year = as.numeric(Year))
ggplot(highest_USA,
aes(x = Year,
y = total, colour = City, group = City)) +
geom_bar(stat = "identity", lwd = 1) +
xlab("Year") +
ylab("Count") +
scale_x_continuous(breaks = c(1970, 1980, 1990, 2000, 2010, 2020), limits = c(1970, 2016)) +
ggtitle("U.S. City Terrorist Attacks") +
theme(legend.title = element_text(color = "black", size = 10, face = "bold")) +
theme_set(theme_bw()) +
labs(subtitle = "by City (w/o New York City)",
caption = "Source: GTD")
```
#### Across these U.S. cities, which had the deadliest attacks?
```{r echo=FALSE, message=FALSE, warning=FALSE}
highest_killed_USA <- terrorism %>%
filter(Country == "United States") %>%
filter(!City == "New York City") %>%
group_by(Year, City, Casualties) %>%
summarise(total = sum(Casualties)) %>%
arrange(desc(total))
output <- distinct(highest_killed_USA, Year, .keep_all = TRUE)
head(output)
```
#### Shiny App Link:
https://saguilar.shinyapps.io/GTDB/
#### RPubs Presentation:
http://rpubs.com/securl/revealjspresent
#### Presentation created using REVEAL.JS
> - https://revealjs.com/#/
> - https://rmarkdown.rstudio.com/revealjs_presentation_format.html
#### Github Repo:
> - https://github.com/dataSeanC
## QUESTIONS?