KPopiela_final p1

##Research Question

#I will need to do some more thorough testing to make sure I can actually do this, but I'd like to focus my final project on ethnic violence since I know a lot about it (I wrote my undergrad thesis on ethno-religious violence in the Polish-Ukrainian borderlands). I found some data sets for my DACSS-601 intensive final that were pretty useful - I found a lot of information but now that I will have the statistical background I'd like to see if I can go further with it. Specifically in the sense of finding out statistics related to the likelihood of an eruption of ethnic violence in countries that fit specific criteria on paper. I can come up with a different research question for this topic area if my initial idea isn't feasible though.  

#These criteria are as follows:  
# - The population doesn't have an overwhelming ethnic majority; there are 2+ groups, each with substantial numbers.  
# - History of socio-political repression by one group against the other(s) when said group has political power/alternating episodes of targeted political repression depending on what group holds a political majority.  
# - The country/population is in a state of severe socio-political instability (war, territorial conquest, political power vacuum, etc.)  

#To make this a little less challenging, I'm going to simplify things for myself. First, I will narrow the data down geographically and temporally - I'm going to focus on former Yugoslav states and the former USSR (I might change the location though). Second, since the data sets I'll be using are pretty big, I'm also going to look at certain columns based on the criteria I presented above (ethnic groups involved, group(s) being oppressed and by whom, and presence/absence of political instability). 

# Research Question: Based on what the data show, (1) is there actually a higher probability of ethnic armed conflict/war when these conditions, and (2) does one particular condition have a greater effect on political stability than the others?
library(readr)
library(poliscidata)
Registered S3 method overwritten by 'gdata':
  method         from  
  reorder.factor gplots
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(ggplot2)
library(foreign)

##Summary Stats/Visuals

#All data sets I will be using are from the Harvard Dataverse and they are as follows:  

#     Lars-Erik Cederman; Brian Min; Andreas Wimmer, 2010, "Ethnic Power Relations dataset", https://doi.org/10.7910/DVN/NDJUJM, Harvard Dataverse, V1, UNF:5:k4xxXC2ASI204QZ4jqvUrQ== [fileUNF]  
#     Lars-Erik Cederman; Brian Min; Andreas Wimmer, 2010, "Ethnic Armed Conflict dataset", https://doi.org/10.7910/DVN/K3OIJQ, Harvard Dataverse, V1  
#    UCDP/PRIO Armed Conflict Dataset version 22.1. Gleditsch, Nils Petter, Peter Wallensteen, Mikael Eriksson, Margareta Sollenberg, and Håvard Strand (2002) Armed Conflict 1946-2001: A New Dataset. Journal of Peace Research 39(5).

#I don't need to look at these in any particular order, so I'm just going to present them in the order they are in above. 
# Data set 1: "Ethnic Power Relations dataset"

ethnic_power_relations <- MASTER_EPR_v1_IrgFiR
Error in eval(expr, envir, enclos): object 'MASTER_EPR_v1_IrgFiR' not found
ethnic_power_relations <- ethnic_power_relations %>%
  select(statename,from,to,group,status,size) %>%
  filter(statename == c("Albania","Croatia","Bosnia and Herzegovina","Yugoslavia","Macedonia","Poland","Ukraine","Russia","Hungary","Romania","Bulgaria"), from >= 1980) 
Error in select(., statename, from, to, group, status, size): object 'ethnic_power_relations' not found
ethnic_power_relations
Error in eval(expr, envir, enclos): object 'ethnic_power_relations' not found
#Data set 2: "Ethnic Armed Conflict dataset"
#I'm going to use select() to look at "country", "startyr", "endyr", and "ETHNOWAR". Then I will use filter() to meet my geographic requirements.

ethnic_armed_conflict <- EAC_edPcfy
Error in eval(expr, envir, enclos): object 'EAC_edPcfy' not found
ethnic_armed_conflict <- ethnic_armed_conflict %>%
  select(country, startyr, endyr, ETHNOAIMS, ETHNOWAR) %>%
  filter(country == c("Croatia","Yugoslavia","Bosnia and Herzegovina","USSR","Russia"),startyr >= 1980)
Error in select(., country, startyr, endyr, ETHNOAIMS, ETHNOWAR): object 'ethnic_armed_conflict' not found
ethnic_armed_conflict
Error in eval(expr, envir, enclos): object 'ethnic_armed_conflict' not found
#This data set is based off of another one (Gleditsch, Nils Petter, Peter Wallensteen, Mikael Eriksson, Margareta Sollenberg, and Håvard Strand (2002) Armed Conflict 1946-2001: A New Dataset. Journal of Peace Research 39(5).) so I will include that as well

#NOTE: I don't know why only 2 of the 5 countries I listed are showing up
#Data set 3: "UCDP/PRIO Armed Conflict Dataset" version 22.1

UCDP_Prio_AC <- ucdp_prio_acd_221_wKBkVs
Error in eval(expr, envir, enclos): object 'ucdp_prio_acd_221_wKBkVs' not found
UCDP_Prio_AC <- UCDP_Prio_AC %>%
  select(location, side_a, side_b, start_date) %>%
  filter(location == c("Yugoslavia","Croatia","Serbia","Russia"))
Error in select(., location, side_a, side_b, start_date): object 'UCDP_Prio_AC' not found
UCDP_Prio_AC
Error in eval(expr, envir, enclos): object 'UCDP_Prio_AC' not found
#NOTE: I don't know why this one is doing the same thing as the previous one.
#I'm obviously going to do more in-depth work with all three data sets, these (below) are just kind of a sample of what I will be doing.
ethnic_power_relations %>%
  ggplot(mapping=aes(x=group,y=size,col=status)) + geom_point() + coord_flip()
Error in ggplot(., mapping = aes(x = group, y = size, col = status)): object 'ethnic_power_relations' not found
ethnic_power_relations %>%
  summarise(mean(size))
Error in summarise(., mean(size)): object 'ethnic_power_relations' not found
ethnic_power_relations %>%
  count(status)
Error in count(., status): object 'ethnic_power_relations' not found