-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuseR_gndr_lvl_ethnicity_ctry_script.R
150 lines (111 loc) · 6.7 KB
/
useR_gndr_lvl_ethnicity_ctry_script.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# SET "useR" FOLDER AS WORKING DIRECTORY TO RUN THIS SCRIPT
# Cumulative Gender Data-Frame
library(dplyr)
load("useR2016/useR2016_s.RData")
gender_2016_df <- useR20162 %>% group_by(Q2) %>% summarise(count = n())
gender_2016_df <- data.frame(append(gender_2016_df, c(Year=2016), after = 0))
colnames(gender_2016_df) <- c('Year', 'Type', 'Count')
load("useR2017/useR2017_s.RData")
gender_2017_df <- useR20172 %>% group_by(Gender) %>% summarise(count = n())
gender_2017_df <- data.frame(append(gender_2017_df, c(Year=2017), after = 0))
colnames(gender_2017_df) <- c('Year', 'Type', 'Count')
gender_2018_df <- read.csv("useR2018/stats_from_local_organisers/genders.csv")
gender_2018_df <- data.frame(append(gender_2018_df, c(Year=2018), after = 0))
colnames(gender_2018_df) <- c('Year', 'Type', 'Count')
gender_2019_df <- read.csv("useR2019/stats_from_local_organisers/genders.csv", header = F)
gender_2019_df <- data.frame(append(gender_2019_df, c(Year=2019), after = 0))
colnames(gender_2019_df) <- c('Year', 'Type', 'Count')
load("useR2020/useR2020_s.RData")
gender_2020_df <- useR2020_s %>% group_by(`What is your gender?`) %>% summarise(count = n())
gender_2020_df <- data.frame(append(gender_2020_df, c(Year=2020), after = 0))
colnames(gender_2020_df) <- c('Year', 'Type', 'Count')
cumm_gender_df <- do.call("rbind", list(gender_2016_df, gender_2017_df, gender_2018_df,
gender_2019_df, gender_2020_df))
View(cumm_gender_df)
# Cumulative Levels Data-Frame
level_2016_df <- useR20162 %>% group_by(Q1) %>% summarise(count = n())
level_2016_df <- data.frame(append(level_2016_df, c(Year=2016), after = 0))
colnames(level_2016_df) <- c('Year', 'Level', 'Count')
level_2017_df <- useR20172 %>% group_by(EmploymentStatus) %>% summarise(count = n())
level_2017_df <- data.frame(append(level_2017_df, c(Year=2017), after = 0))
colnames(level_2017_df) <- c('Year', 'Level', 'Count')
level_2018_df <- read.csv("useR2018/stats_from_local_organisers/levels.csv")
level_2018_df <- data.frame(append(level_2018_df, c(Year=2018), after = 0))
colnames(level_2018_df) <- c('Year', 'Level', 'Count')
level_2019_df <- read.csv("useR2019/stats_from_local_organisers/levels.csv", header = F)
level_2019_df <- data.frame(append(level_2019_df, c(Year=2019), after = 0))
colnames(level_2019_df) <- c('Year', 'Level', 'Count')
level_2020_df <- useR2020_s %>% group_by(`What is your current employment status? If you are employed in multiple sectors or both work and study, select all that apply:`) %>% summarise(count = n())
level_2020_df <- data.frame(append(level_2020_df, c(Year=2020), after = 0))
colnames(level_2020_df) <- c('Year', 'Level', 'Count')
level_2021_df <- read.csv("useR2021/stats_from_local_organisers/levels.csv")
level_2021_df <- data.frame(append(level_2021_df, c(Year=2021), after = 0))
colnames(level_2021_df) <- c('Year', 'Level', 'Count')
cumm_level_df <- do.call("rbind", list(level_2016_df, level_2017_df, level_2018_df,
level_2019_df, level_2020_df, level_2021_df))
View(cumm_level_df)
# Cumulative Ethnicity Type Data-Frame
ethn_2016_df <- useR20162 %>% group_by(`survey_data$Q4`) %>% summarise(count = n())
ethn_2016_df <- data.frame(append(ethn_2016_df, c(Year=2016), after = 0))
colnames(ethn_2016_df) <- c('Year', 'Ethnicity', 'Count')
ethn_2017_df <- useR20172 %>% group_by(`useR2017_survey$EthnicGroup`) %>% summarise(count = n())
ethn_2017_df <- data.frame(append(ethn_2017_df, c(Year=2017), after = 0))
colnames(ethn_2017_df) <- c('Year', 'Ethnicity', 'Count')
ethn_2017_df <- ethn_2017_df[-c(1:4),]
load("useR2018/stats_from_local_organisers/useR2018_ethnicity.RData")
ethn_2018_df <- user2018 %>% group_by(`To what ethnic group(s) do you identify?`) %>% summarise(count = n())
ethn_2018_df <- data.frame(append(ethn_2018_df, c(Year=2018), after = 0))
colnames(ethn_2018_df) <- c('Year', 'Ethnicity', 'Count')
load("useR2020/useR2020_ethnicity.RData")
ethn_2020_df <- which_ethnicity %>% group_by(ethnicity_group) %>% summarise(count = n())
ethn_2020_df <- data.frame(append(ethn_2020_df, c(Year=2020), after = 0))
colnames(ethn_2020_df) <- c('Year', 'Ethnicity', 'Count')
cumm_ethnicity_df <- do.call("rbind", list(ethn_2016_df, ethn_2017_df,
ethn_2018_df, ethn_2020_df))
View(cumm_ethnicity_df)
# Cumulative Country Count Data-Frame
library(countrycode)
country_name <-
countrycode::codelist %>%
as_tibble() %>%
select(
name = country.name.en, country = iso3c
) %>%
dplyr::mutate(country = dplyr::case_when(
name == "Kosovo" ~ "XK",
TRUE ~ country
)) %>%
filter(!is.na(country)) %>%
rename(iso_code = country)
ctry_2016_df <- useR20162 %>% group_by(Q5) %>% summarise(count = n())
code <- countrycode(ctry_2016_df$Q5, origin = 'country.name', destination = 'iso3c')
ctry_2016_df$iso <- code
ctry_2016_df <- subset(ctry_2016_df, select = c(count, iso))
main_df <- left_join(country_name, ctry_2016_df, by = c("iso_code" = "iso"))
ctry_2017_df <- useR20172 %>% group_by(CurrentResidenceCountry) %>% summarise(count = n())
code <- countrycode(ctry_2017_df$CurrentResidenceCountry, origin = 'country.name', destination = 'iso3c')
ctry_2017_df$iso <- code
ctry_2017_df <- subset(ctry_2017_df, select = c(count, iso))
main_df <- left_join(main_df, ctry_2017_df, by = c("iso_code" = "iso"))
ctry_2018_df <- read.csv("useR2018/stats_from_local_organisers/countries.csv")
code <- countrycode(ctry_2018_df$Booking.Country, origin = 'country.name', destination = 'iso3c')
ctry_2018_df$iso <- code
ctry_2018_df <- subset(ctry_2018_df, select = c(n, iso))
main_df <- left_join(main_df, ctry_2018_df, by = c("iso_code" = "iso"))
ctry_2019_df <- read.csv("useR2019/stats_from_local_organisers/countries.csv", header = F)
code <- countrycode(ctry_2019_df$V1, origin = 'country.name', destination = 'iso3c')
ctry_2019_df$iso <- code
ctry_2019_df <- subset(ctry_2019_df, select = c(V2, iso))
main_df <- left_join(main_df, ctry_2019_df, by = c("iso_code" = "iso"))
ctry_2020_df <- useR2020_s %>% group_by(`In what country do you currently reside?`) %>% summarise(count = n())
code <- countrycode(ctry_2020_df$`In what country do you currently reside?`, origin = 'country.name', destination = 'iso3c')
ctry_2020_df$iso <- code
ctry_2020_df <- subset(ctry_2020_df, select = c(count, iso))
main_df <- left_join(main_df, ctry_2020_df, by = c("iso_code" = "iso"))
ctry_2021_df <- read.csv("useR2021/stats_from_local_organisers/countries.csv")
code <- countrycode(ctry_2021_df$country, origin = 'country.name', destination = 'iso3c')
ctry_2021_df$iso <- code
ctry_2021_df <- subset(ctry_2021_df, select = c(n, iso))
main_df <- left_join(main_df, ctry_2021_df, by = c("iso_code" = "iso"))
colnames(main_df) <- c('Country', 'ISO_Code', '2016', '2017', '2018', '2019', '2020', '2021')
View(main_df)