-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2 analysis_sr_source.R
More file actions
44 lines (28 loc) · 1.23 KB
/
Copy path2 analysis_sr_source.R
File metadata and controls
44 lines (28 loc) · 1.23 KB
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
# Prepare the datasets: ----
rm(list = ls())
# Load economic and geographical groups:
country_group <- read_xlsx("../When_where_and_why_material/raw_data/country_group.xlsx") %>%
rename(country_code = ifscode) %>%
select(country_code, adv, eme, lidc)
geo_group <- readRDS("../When_where_and_why_material/intermediate_data/country_group_geography_clean.RDS")
# Load dataset:
paths=c("../When_where_and_why_material/intermediate_data/rgdp_cleaned.RDS",
"../When_where_and_why_material/intermediate_data/inflation_cleaned.RDS")
names=c("growth",
"inflation")
final_sr <- paths %>%
map(~ readRDS(.x)) %>%
map(~ .x %>% select(country_code,country,year,targety_first,targety_last,matches("variable[1-4]$"))) %>%
map(~ .x %>% merge(country_group, by = c("country_code"))) %>%
map(~ .x %>% merge(geo_group, by = c("country_code"),all.x = T)) %>%
map(~ .x %>% as_tibble())
names(final_sr) <- names
# Years of recession:
years_recession <- final_sr[["growth"]] %>%
mutate(recession = case_when(targety_first <= 0 ~ 1,
TRUE ~ 0)) %>%
select(country_code, year, recession)
# Source and produce output: ----
list.files() %>%
str_subset("^2.\\d") %>%
walk(~ source(.x))