forked from dgrtwo/unvotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
un-data.R
61 lines (51 loc) · 2.06 KB
/
un-data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
library(dplyr)
library(readxl)
library(countrycode)
library(tidyr)
library(forcats)
library(usethis)
vlevels <- c("yes", "abstain", "no")
load("data-raw/UNVotes2021.RData")
un_votes <- completeVotes %>%
filter(vote <= 3) %>%
mutate(
country = countrycode(ccode, "cown", "country.name"),
country_code = countrycode(ccode, "cown", "iso2c"),
# Match based on old version of data from unvotes package
country_code = case_when(
country == "Czechoslovakia" ~ "CS",
country == "Yugoslavia" ~ "YU",
country == "German Democratic Republic" ~ "DD",
country == "Yemen People's Republic" ~ "YD",
TRUE ~ country_code
),
country = if_else(!is.na(Countryname) & Countryname == "German Federal Republic", "Federal Republic of Germany", country)
) %>%
select(rcid, country, country_code, vote) %>%
mutate(vote = as.character(vote)) %>%
mutate(vote = fct_recode(vote, yes = "1", abstain = "2", no = "3"))
usethis::use_data(un_votes, overwrite = TRUE)
descriptions <- completeVotes %>%
select(session, rcid, abstain, yes, no, importantvote, date, unres, amend, para, short, descr, me, nu, di, hr, co, ec) %>%
distinct(rcid, .keep_all = TRUE)
un_roll_calls <- descriptions %>%
select(rcid, session, importantvote:descr) %>%
mutate(rcid = as.integer(rcid),
date = as.Date(date)) %>%
arrange(rcid)
usethis::use_data(un_roll_calls, overwrite = TRUE)
un_roll_call_issues <- descriptions %>%
select(rcid, me:ec) %>%
gather(short_name, value, me:ec) %>%
mutate(rcid = as.integer(rcid),
value = as.numeric(value)) %>%
filter(value == 1) %>%
select(-value) %>%
mutate(issue = fct_recode(short_name,
"Palestinian conflict" = "me",
"Nuclear weapons and nuclear material" = "nu",
"Colonialism" = "co",
"Human rights" = "hr",
"Economic development" = "ec",
"Arms control and disarmament" = "di"))
usethis::use_data(un_roll_call_issues, overwrite = TRUE)