-
Notifications
You must be signed in to change notification settings - Fork 0
/
survey_data_cleaning.R
64 lines (55 loc) · 1.35 KB
/
survey_data_cleaning.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
61
62
63
64
library(data.table)
library(feather)
# Survey data
dev_survey_19 <- fread("./SOresults/SO_survey_results_2019.csv")
dev_survey_19 <- dev_survey_19[, .(
country = Country,
UndergradMajor,
DevType,
Age,
Gender
)]
orig_survey_countries <- c(
"Antigua and Barbuda",
"Brunei Darussalam",
"Côte d'Ivoire",
"Lao People's Democratic Republic",
"Libyan Arab Jamahiriya",
"The former Yugoslav Republic of Macedonia",
"Republic of Moldova",
"Congo, Republic of the...",
"Russian Federation",
"Saint Vincent and the Grenadines",
"Saint Kitts and Nevis",
"Trinidad and Tobago",
"Syrian Arab Republic",
"United Republic of Tanzania",
"United Kingdom",
"United States",
"Venezuela, Bolivarian Republic of...",
"Viet Nam"
)
replace_survey_countries <- c(
"Antigua",
"Brunei",
"Ivory Coast",
"Laos",
"Libya",
"Macedonia",
"Moldova",
"Republic of Congo",
"Russia",
"Saint Vincent",
"Saint Kitts",
"Trinidad",
"Syria",
"Tanzania",
"UK",
"USA",
"Venezuela",
"Vietnam"
)
for (i in 1:length(replace_survey_countries)) {
dev_survey_19[country %like% orig_survey_countries[i], country := replace_survey_countries[i]]
}
write_feather(dev_survey_19, "dev_survey_19.feather")