Skip to content
Snippets Groups Projects
Commit 22d79f3a authored by Ingram Jaccard's avatar Ingram Jaccard
Browse files

edit full code

parent 6801688b
No related branches found
No related tags found
No related merge requests found
......@@ -272,7 +272,7 @@ Table S4 shows our mapping between the EUROSTAT HBS consumption categories and t
```{r tableS4}
labels = read.csv(here("/analysis/preprocessing/Exiobase_T_labels_ixi_w_coicop_mapping_no_rent.csv")) %>%
labels = read.csv(here("/analysis/preprocessing/Exiobase_T_labels_ixi_w_coicop_mapping.csv")) %>%
select(V2,coicop,five_sectors) %>%
unique()
......
......@@ -3196,9 +3196,9 @@ results_formatted = results_recombined %>%
#write_rds(results_formated, here("/results_formated.rds"))
write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi_pps_hh_no_rent.csv"))
write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi.csv"))
write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi_pps_hh_no_rent.rds"))
write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi.rds"))
#write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi_pps_ae.csv"))
......@@ -7554,7 +7554,7 @@ write.csv(results_formatted_with_direct_FD_fp, paste0(data_dir_income_stratified
```
# European exp deciles
# European expenditure deciles
```{r european-expenditure-deciles, eval = FALSE}
......@@ -7574,11 +7574,11 @@ pacman::p_load(tidyverse,
target_eu_ntiles = 10
source(here("code", "helper_functions.R"))
#source(here("code", "helper_functions.R"))
# 1) load MRIO result file
dat_results_raw = read_rds(here("data", "results_formatted_method1_ixi_pps_hh_no_rent.rds")) %>%
dat_results_raw = read_rds(here("analysis", "preprocessing", "income-stratified-footprints",
"results_formatted_method1_ixi.rds")) %>%
ungroup() %>%
mutate(year= strtoi(year)) %>%
rename(iso2 = geo)
......@@ -7591,7 +7591,8 @@ country_codes = ISOcodes::ISO_3166_1 %>%
mutate(iso2 = if_else(iso2=="GB", "UK", iso2))
# 2) load Eurostat household data - should show how I get to 'total_private_households.csv' - see code chunk in SI - move to here.
hh_data = read_csv(here("data", "total_private_households.csv")) %>%
hh_data = read_csv(here("analysis", "preprocessing", "income-stratified-footprints",
"total_private_households.csv")) %>%
mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %>%
rename(iso2 = geo) %>%
group_by(iso2) %>%
......@@ -7601,7 +7602,9 @@ hh_data = read_csv(here("data", "total_private_households.csv")) %>%
select(-total_private_households)
#3) Eurostat mean expenditures per household income quintile per household and per adult equivalent
df_expenditure_long = read_csv(here("data",
df_expenditure_long = read_csv(here("analysis",
"preprocessing",
"income-stratified-footprints",
"mean_expenditure_by_quintile_long.csv"),
na = ":") %>%
#filter(year >=2010, geo != "IT") %>%
......@@ -7701,8 +7704,8 @@ df_adult_e_p_hh %>%
df_adult_e_p_hh %>%
filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>%
mutate(quint = parse_number(quintile)) %>%
write_csv(here("data", "adult_eq_per_household.csv"))
mutate(quint = parse_number(quintile)) #%>%
#write_csv(here("data", "adult_eq_per_household.csv"))
# calculate EU expenditure tiles based on loaded mrio result file and adult equivalents.
......@@ -7886,7 +7889,7 @@ df_mapped_result_data = df_mapped_result_2005_data %>%
bind_rows(df_mapped_result_2015_data)
write_csv(df_mapped_result_data,
here(paste0("data/mrio_results_eu_ntile_mapped_n_", target_eu_ntiles, ".csv")))
here(paste0("analysis/data/derived/mrio_results_eu_ntile_mapped_n_", target_eu_ntiles, "_check.csv")))
df_mapped_result_ntiles =
df_mapped_result_2005_ntiles %>% mutate(year=2005) %>%
......@@ -7896,26 +7899,9 @@ df_mapped_result_ntiles =
write_csv(df_mapped_result_ntiles,
here(paste0("data/eu_ntiles_n_", target_eu_ntiles, ".csv")))
######
knitr::opts_chunk$set(echo = FALSE, message=FALSE)
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse,
janitor,
here,
wbstats,
ISOcodes,
viridis,
imputeTS,
hrbrthemes,
wesanderson,
glue)
target_eu_ntiles = 10
source(here("code", "helper_functions.R"))
###### pxp version
# 1) load MRIO result file
dat_results_raw = read_rds(here("data", "results_formatted_method1_pxp_pps_hh_no_rent.rds")) %>%
ungroup() %>%
mutate(year= strtoi(year)) %>%
......@@ -8229,25 +8215,7 @@ df_mapped_result_ntiles =
write_csv(df_mapped_result_ntiles,
here(paste0("data/eu_ntiles_n_", target_eu_ntiles, "_pxp.csv")))
######
knitr::opts_chunk$set(echo = FALSE, message=FALSE)
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse,
janitor,
here,
wbstats,
ISOcodes,
viridis,
imputeTS,
hrbrthemes,
wesanderson,
glue)
target_eu_ntiles = 10
source(here("code", "helper_functions.R"))
###### alternative method, ixi version
# 1) load MRIO result file
dat_results_raw = read_rds(here("data", "results_formatted_method2_ixi_pps_hh_no_rent.rds")) %>%
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment