This file contains 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
# metadata | |
data_source <- "https://docs.google.com/spreadsheets/d/1xa0iLqYKz8x9Yc_rfhtmSOJQ2EGgeUVjvV4A8LsIaxY/htmlview?sle=true#gid=0" | |
data_collectors <- "Jeremy Pressman (@djpressman, U of Connecticut) and\nErica Chenoweth (@EricaChenoweth, U of Denver)" | |
code_gist <- "https://gist.github.com/benmarwick/a1ac9c7235ebef542824512162ff2f44" | |
# ------------------------------------------------------------------------ | |
# read in data from google sheets to get a data frame |
This file contains 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
# This script converts Freedom House's annual Freedom in the World data from | |
# the ugly, table-like Excel format in which it's posted into a data frame in R. | |
# It is set up to work on future updates, too, and should automatically adjust | |
# as years or countries are added. | |
# | |
# Before running this script: | |
# | |
# 1. Open a browser & go to http://www.freedomhouse.org/report-types/freedom-world | |
# | |
# 2. Download the file "Country ratings and status, FIW 1973-2013(EXCEL)" |
This file contains 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
# Clear the workspace | |
rm(list=ls(all=TRUE)) | |
# Set working directory to location of extracted daily update and .txt file with column headers | |
# setwd("PUT YOUR DIRECTORY NAME HERE") | |
# Load function to return subset involving violence against civilians | |
extractor <- function(date) { | |
filename <- paste(date,"export.csv", sep=".") | |
dailies <- read.delim(filename, header=FALSE) |
This file contains 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
# Housekeeping: clear workspace and load packages | |
rm(list=ls(all=TRUE)) | |
library(lubridate) | |
library(RgoogleMaps) | |
library(ggmap) | |
library(mapproj) | |
library(ggplot2) | |
library(plyr) | |
# Load 2011 GDELT data from http://eventdata.psu.edu/data.dir/GDELT.html |