Last active
October 5, 2017 23:11
-
-
Save basilesimon/361d712434aeb507987667d7727cb4b6 to your computer and use it in GitHub Desktop.
Distribution of stikes per day by Coalition aircraft in Iraq and Syria (Aug. 2014 - June 2017 included)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(ggridges) | |
# import and simplify before we manipulate | |
dataset <- read_csv('~/Downloads/Coalition bombing timeline & geolocate - Sheet1.csv') | |
d <- dataset %>% | |
select(Date, `Strike Iraq`, `Strike Syria`) %>% | |
replace(is.na(.), 0) | |
# parse dates | |
d$Date <- as.Date(d$Date, format = '%d/%m/%Y') | |
# group by month and calculate daily tally | |
d.sum <- d %>% | |
group_by(Date) %>% | |
summarise(tally = sum(`Strike Iraq`, `Strike Syria`)) %>% | |
na.omit() | |
d.sum$month <- cut(d.sum$Date, breaks = 'month') | |
ggplot(d.sum, aes(x=tally, y=month)) + | |
geom_density_ridges(scale = 5, size = 0.25, rel_min_height = 0.03) + | |
theme_ridges() | |
# group by year and calculate monthly tally | |
d.month <- d.sum %>% | |
group_by(month) %>% | |
summarise(tally=sum(tally)) %>% | |
na.omit() | |
d.month$month <- as.Date(d.month$month, format = '%Y-%m-%d') | |
d.month$year <- cut(d.month$month, breaks = 'year') | |
ggplot(d.month, aes(x=tally, y=year)) + | |
geom_density_ridges(scale = 3, size = 0.25, rel_min_height = 0.03) + | |
theme_ridges() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment