Created
November 15, 2017 23:04
-
-
Save svmiller/afad8b8535e891799c7543d0ffaff5d5 to your computer and use it in GitHub Desktop.
Poking around Fariss' (2014) LHR data.
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
library(tidyverse) | |
library(lubridate) # just in case I need to manipulate a date | |
library(stringr) # just in case I need to manipulated a string | |
library(stevemisc) # for my personal theme | |
library(scales) # just in case I need to fudge a y-axis to be a scale | |
library(knitr) # just in case I need a markdown table | |
# I'm going to assume you have Fariss' data downloaded somewhere. Here's what mine looks like. | |
LHR <- read_csv("~/Dropbox/data/latent-human-rights/HumanRightsProtectionScores_v2.04.csv") | |
LHR %>% | |
filter(COW == 2 | COW == 710) %>% | |
mutate(Country = ifelse(COW == 2, "United States", "China"), | |
lwr = NA) %>% | |
ggplot(.,aes(YEAR, latentmean, group = Country, color=Country, | |
ymin = latentmean - 1.96*latentsd, ymax = latentmean + 1.96*latentsd)) + | |
theme_steve() + theme(legend.position="bottom") + | |
geom_ribbon(aes(fill = Country), alpha = I(0.2), color = "black") + geom_line() + | |
ylab("Mean Latent Human Rights Protection") + xlab("Year") + | |
scale_x_continuous(breaks = seq(1950, 2015, by = 5)) + | |
labs(title = "Human Rights Protection Scores for the U.S. and China, 1949-2013", | |
subtitle = "We oberve a clear contrast between the two starting in 1965 but observe the United States' downward trend.", | |
caption = "Data: Fariss' Latent Human Rights Protection Scores (v. 2.04)") | |
LHR %>% | |
filter(COW == 2 | COW == 20 | COW == 70) %>% | |
mutate(Country = ifelse(COW == 2, "United States", NA), | |
Country = ifelse(COW == 20, "Canada", Country), | |
Country = ifelse(COW == 70, "Mexico", Country), | |
lwr = NA) %>% | |
ggplot(.,aes(YEAR, latentmean, group = Country, color=Country, | |
ymin = latentmean - 1.96*latentsd, ymax = latentmean + 1.96*latentsd)) + | |
theme_steve() + theme(legend.position="bottom") + | |
geom_ribbon(aes(fill = Country), alpha = I(0.2), color = "black") + geom_line() + | |
ylab("Mean Latent Human Rights Protection") + xlab("Year") + | |
scale_x_continuous(breaks = seq(1950, 2015, by = 5)) + | |
labs(title = "Human Rights Protection Scores for the U.S., Canada, and Mexico, 1949-2013", | |
subtitle = "Notice the U.S. is not exactly a world leader in human rights protections despite demonstrations to the contrary.", | |
caption = "Data: Fariss' Latent Human Rights Protection Scores (v. 2.04)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment