Skip to content

Instantly share code, notes, and snippets.

@AABoyles
Created April 8, 2015 14:36
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 AABoyles/696a4aa08e0baf209452 to your computer and use it in GitHub Desktop.
Save AABoyles/696a4aa08e0baf209452 to your computer and use it in GitHub Desktop.
Event Distribution over Weekdays in ICEWS
if(!require("devtools")){
install.packages("devtools")
library("devtools")
}
install_github("aaboyles/phoxy")
library("phoxy")
library("data.table")
library("lubridate")
library("ggplot2")
icews <- data.table(ingest_icews("rawdata"))
daily <- icews %>%
group_by(Event.Date) %>%
summarise(Weekday = wday(ymd(Event.Date), label = TRUE), NumEvents = n()) %>%
filter(!is.na(Weekday))
perweekdays <- daily %>%
group_by(Weekday) %>%
summarise(SumEvents = sum(NumEvents)) %>%
filter(!is.na(Weekday))
ggplot(perweekdays, aes(Weekday, SumEvents)) +
geom_bar(stat="identity", aes(fill=Weekday)) +
labs(y="Total Number of Events", title="Event distribution over Weekdays in ICEWS") +
theme(legend.position="none")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment