diff --git a/analysis/preprocessing/full_code_europe.inequality.Rmd b/analysis/preprocessing/full_code_europe.inequality.Rmd index f0793e7f3aaac56fa952a287d861bda8e32c6f51..8859aef11f01f44a5588fb14807dcea9dbf97f0f 100644 --- a/analysis/preprocessing/full_code_europe.inequality.Rmd +++ b/analysis/preprocessing/full_code_europe.inequality.Rmd @@ -18,28 +18,31 @@ This file contains all code to estimate the European income-stratified footprint We first load required R packages. -```{r setup, warning=F, message=F} - -# Libraries: -library(tidyverse) -library(ggpubr) -library(knitr) -library(kableExtra) -library(readxl) -library(latex2exp) -library(stargazer) -library(plm) -library(lmtest) -library(tseries) -library(RColorBrewer) -library(rworldmap) - -require(tidyverse) -require(readr) -require(janitor) +```{r setup, echo = FALSE, include = FALSE, message = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + warning = FALSE, + message = FALSE, + echo = FALSE, + comment = "#>" +) + +if (!require("pacman")) install.packages("pacman") +pacman::p_load(tidyverse, + janitor, + here, + wbstats, + ISOcodes, + viridis, + hrbrthemes, + wesanderson, + glue, + ggridges, + patchwork) ``` + # Exiobase ```{r exiobase, eval = FALSE} diff --git a/analysis/preprocessing/full_code_europe.inequality.html b/analysis/preprocessing/full_code_europe.inequality.html index 1de3567d71a6cc11bc3309dff4beb74423417f61..45f9cead9cbac6a5c585931bce843a529b6ffd5a 100644 --- a/analysis/preprocessing/full_code_europe.inequality.html +++ b/analysis/preprocessing/full_code_europe.inequality.html @@ -1669,9695 +1669,12 @@ require(janitor)</code></pre> </div> <div id="exiobase" class="section level1"> <h1>Exiobase</h1> -<pre class="r"><code># EXIOBASE_cluster_ixi_version - -# data directories (on cluster) -data_dir_exiobase = paste("/",file.path("data","metab","Exiobase", fsep=.Platform$file.sep),sep="") - -years_exiobase_ixi = c(2005,2010,2015) - -for (i in years_exiobase_ixi){ - -year_current = i - -A = read.delim(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/A.txt"),header = F) - -write.csv(A, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/A.csv")) - -A = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/A.csv",sep = ""),row.names=NULL,as.is=TRUE)[4:7990,4:7990] -A[is.na(A)]=0 -A = mapply(A, FUN = as.numeric) -A = matrix(data = A, ncol = 7987, nrow = 7987) - -L = solve(diag(dim(A)[1])-A) # this solves the Leontief inverse initially -L[is.na(L)]=0 - - -# final demand - -FD = read.delim(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/Y.txt"),header = F) - -write.csv(FD, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/Y.csv")) - - -Exiobase_T_labels_ixi = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/Y.csv"))[4:7990,1:3] - -write.csv(Exiobase_T_labels_ixi, paste0(data_dir_exiobase, "/Exiobase_T_labels_ixi.csv")) - -Exiobase_FD_labels_ixi = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/Y.csv"))[1:3,4:346] - -write.csv(Exiobase_FD_labels_ixi, paste0(data_dir_exiobase, "/Exiobase_FD_labels_ixi.csv")) - - -FD = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/Y.csv",sep=""),row.names=NULL,as.is=TRUE)[4:7990,4:346] -FD[is.na(FD)]=0 -FD = mapply(FD, FUN = as.numeric) -FD = matrix(data=FD,ncol=343,nrow=7987) - -write.csv(FD, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/FD_",year_current,"_ixi.csv")) - - -# total output -total_output = L %*% rowSums(FD) - -write.csv(total_output, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/total_output_",year_current,"_ixi.csv")) - - -# direct environmental vectors -satellite = read.delim(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/F.txt"),header = F) - -write.csv(satellite, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/F.csv")) - - -satellite = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/F.csv",sep=""),row.names=NULL,as.is=TRUE)[3:1115,3:7989] -satellite[is.na(satellite)]=0 -satellite = mapply(satellite, FUN = as.numeric) -satellite = matrix(data=satellite,ncol=7987,nrow=1113) - - -write.csv(satellite, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/satellite_",year_current,"_ixi.csv")) - - -# direct environmental vectors on final demand - -satellite_FD = read.delim(paste0(data_dir_exiobase, "/IOT_", year_current, "_ixi/satellite/F_hh.txt"),header = F) - -write.csv(satellite_FD, paste0(data_dir_exiobase, "/IOT_", year_current, "_ixi/satellite/F_hh.csv")) - - -# CO2 combustion air -CO2_combustion_air = satellite[24,] -#write.csv(CO2_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/co2_combustion_air_",year_current,"_ixi.csv")) -DIV_co2_combustion_air = CO2_combustion_air/total_output -DIV_co2_combustion_air[is.na(DIV_co2_combustion_air)]=0 -DIV_co2_combustion_air[DIV_co2_combustion_air == Inf]<-0 -#write.csv(DIV_co2_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/DIV_co2_combustion_air_",year_current,"_ixi.csv")) -TIV_co2_combustion_air = as.vector(DIV_co2_combustion_air) %*% L - -write.csv(TIV_co2_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_combustion_air_",year_current,"_ixi.csv")) - -TIV_breakdown_co2_combustion_air = as.vector(DIV_co2_combustion_air) * L -TIV_breakdown_co2_combustion_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_co2_combustion_air) -TIV_country_breakdown_co2_combustion_air_w_labels = t(TIV_breakdown_co2_combustion_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_combustion_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_combustion_air_",year_current,"_ixi.csv")) - - -# CO2 non-combustion air -## cement -CO2_noncombustion_cement_air = satellite[93,] -DIV_co2_noncombustion_cement_air = CO2_noncombustion_cement_air/total_output -DIV_co2_noncombustion_cement_air[is.na(DIV_co2_noncombustion_cement_air)]=0 -DIV_co2_noncombustion_cement_air[DIV_co2_noncombustion_cement_air == Inf]<-0 -TIV_co2_noncombustion_cement_air = as.vector(DIV_co2_noncombustion_cement_air) %*% L - -write.csv(TIV_co2_noncombustion_cement_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_noncombustion_cement_air_",year_current,"_ixi.csv")) - -TIV_breakdown_co2_noncombustion_cement_air = as.vector(DIV_co2_noncombustion_cement_air) * L -TIV_breakdown_co2_noncombustion_cement_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_co2_noncombustion_cement_air) -TIV_country_breakdown_co2_noncombustion_cement_air_w_labels = t(TIV_breakdown_co2_noncombustion_cement_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_noncombustion_cement_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_ixi.csv")) - -## lime -CO2_noncombustion_lime_air = satellite[94,] -DIV_co2_noncombustion_lime_air = CO2_noncombustion_lime_air/total_output -DIV_co2_noncombustion_lime_air[is.na(DIV_co2_noncombustion_lime_air)]=0 -DIV_co2_noncombustion_lime_air[DIV_co2_noncombustion_lime_air == Inf]<-0 -TIV_co2_noncombustion_lime_air = as.vector(DIV_co2_noncombustion_lime_air) %*% L - -write.csv(TIV_co2_noncombustion_lime_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_noncombustion_lime_air_",year_current,"_ixi.csv")) - -TIV_breakdown_co2_noncombustion_lime_air = as.vector(DIV_co2_noncombustion_lime_air) * L -TIV_breakdown_co2_noncombustion_lime_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_co2_noncombustion_lime_air) -TIV_country_breakdown_co2_noncombustion_lime_air_w_labels = t(TIV_breakdown_co2_noncombustion_lime_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_noncombustion_lime_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_ixi.csv")) - - -# CO2 agriculture peat decay air -CO2_agriculture_peatdecay_air = satellite[428,] -DIV_co2_agriculture_peatdecay_air = CO2_agriculture_peatdecay_air/total_output -DIV_co2_agriculture_peatdecay_air[is.na(DIV_co2_agriculture_peatdecay_air)]=0 -DIV_co2_agriculture_peatdecay_air[DIV_co2_agriculture_peatdecay_air == Inf]<-0 -TIV_co2_agriculture_peatdecay_air = as.vector(DIV_co2_agriculture_peatdecay_air) %*% L - -write.csv(TIV_co2_agriculture_peatdecay_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv")) - -TIV_breakdown_co2_agriculture_peatdecay_air = as.vector(DIV_co2_agriculture_peatdecay_air) * L -TIV_breakdown_co2_agriculture_peatdecay_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_co2_agriculture_peatdecay_air) -TIV_country_breakdown_co2_agriculture_peatdecay_air_w_labels = t(TIV_breakdown_co2_agriculture_peatdecay_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_agriculture_peatdecay_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv")) - -# CO2 waste air -## biogenic -CO2_waste_biogenic_air = satellite[438,] -DIV_co2_waste_biogenic_air = CO2_waste_biogenic_air/total_output -DIV_co2_waste_biogenic_air[is.na(DIV_co2_waste_biogenic_air)]=0 -DIV_co2_waste_biogenic_air[DIV_co2_waste_biogenic_air == Inf]<-0 -TIV_co2_biogenic_air = as.vector(DIV_co2_waste_biogenic_air) %*% L - -write.csv(TIV_co2_biogenic_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_biogenic_air_",year_current,"_ixi.csv")) - -TIV_breakdown_co2_biogenic_air = as.vector(DIV_co2_waste_biogenic_air) * L -TIV_breakdown_co2_biogenic_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_co2_biogenic_air) -TIV_country_breakdown_co2_biogenic_air_w_labels = t(TIV_breakdown_co2_biogenic_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_biogenic_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_biogenic_air_",year_current,"_ixi.csv")) - -## fossil -CO2_waste_fossil_air = satellite[439,] -DIV_co2_waste_fossil_air = CO2_waste_fossil_air/total_output -DIV_co2_waste_fossil_air[is.na(DIV_co2_waste_fossil_air)]=0 -DIV_co2_waste_fossil_air[DIV_co2_waste_fossil_air == Inf]<-0 -TIV_co2_waste_fossil_air = as.vector(DIV_co2_waste_fossil_air) %*% L - -write.csv(TIV_co2_waste_fossil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_waste_fossil_air_",year_current,"_ixi.csv")) - -TIV_breakdown_co2_waste_fossil_air = as.vector(DIV_co2_waste_fossil_air) * L -TIV_breakdown_co2_waste_fossil_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_co2_waste_fossil_air) -TIV_country_breakdown_co2_waste_fossil_air_w_labels = t(TIV_breakdown_co2_waste_fossil_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_waste_fossil_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_ixi.csv")) - - -# CH4 combustion air -CH4_combustion_air = satellite[25,] -#write.csv(CH4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/ch4_combustion_air_",year_current,"_ixi.csv")) -CH4_combustion_air = CH4_combustion_air*28 -#write.csv(CH4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/ch4_CO2eq_combustion_air_",year_current,"_ixi.csv")) -DIV_ch4_combustion_air = CH4_combustion_air/total_output -DIV_ch4_combustion_air[is.na(DIV_ch4_combustion_air)]=0 -DIV_ch4_combustion_air[DIV_ch4_combustion_air == Inf]<-0 -#write.csv(DIV_ch4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/DIV_ch4_CO2eq_combustion_air_",year_current,"_ixi.csv")) -TIV_ch4_combustion_air = as.vector(DIV_ch4_combustion_air) %*% L - -write.csv(TIV_ch4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_combustion_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_combustion_air = as.vector(DIV_ch4_combustion_air) * L -TIV_breakdown_ch4_combustion_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_combustion_air) -TIV_country_breakdown_ch4_combustion_air_w_labels = t(TIV_breakdown_ch4_combustion_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_combustion_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_",year_current,"_ixi.csv")) - - -# CH4 noncombustion air -## gas -CH4_noncombustion_gas_air = satellite[68,] -CH4_noncombustion_gas_air = CH4_noncombustion_gas_air*28 -DIV_ch4_noncombustion_gas_air = CH4_noncombustion_gas_air/total_output -DIV_ch4_noncombustion_gas_air[is.na(DIV_ch4_noncombustion_gas_air)]=0 -DIV_ch4_noncombustion_gas_air[DIV_ch4_noncombustion_gas_air == Inf]<-0 -TIV_ch4_noncombustion_gas_air = as.vector(DIV_ch4_noncombustion_gas_air) %*% L - -write.csv(TIV_ch4_noncombustion_gas_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_gas_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_gas_air = as.vector(DIV_ch4_noncombustion_gas_air) * L -TIV_breakdown_ch4_noncombustion_gas_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_gas_air) -TIV_country_breakdown_ch4_noncombustion_gas_air_w_labels = t(TIV_breakdown_ch4_noncombustion_gas_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_gas_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_",year_current,"_ixi.csv")) - -## oil -CH4_noncombustion_oil_air = satellite[69,] -CH4_noncombustion_oil_air = CH4_noncombustion_oil_air*28 -DIV_ch4_noncombustion_oil_air = CH4_noncombustion_oil_air/total_output -DIV_ch4_noncombustion_oil_air[is.na(DIV_ch4_noncombustion_oil_air)]=0 -DIV_ch4_noncombustion_oil_air[DIV_ch4_noncombustion_oil_air == Inf]<-0 -TIV_ch4_noncombustion_oil_air = as.vector(DIV_ch4_noncombustion_oil_air) %*% L - -write.csv(TIV_ch4_noncombustion_oil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_oil_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_oil_air = as.vector(DIV_ch4_noncombustion_oil_air) * L -TIV_breakdown_ch4_noncombustion_oil_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_oil_air) -TIV_country_breakdown_ch4_noncombustion_oil_air_w_labels = t(TIV_breakdown_ch4_noncombustion_oil_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_oil_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_",year_current,"_ixi.csv")) - -## anthracite -CH4_noncombustion_anthracite_air = satellite[70,] -CH4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air*28 -DIV_ch4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air/total_output -DIV_ch4_noncombustion_anthracite_air[is.na(DIV_ch4_noncombustion_anthracite_air)]=0 -DIV_ch4_noncombustion_anthracite_air[DIV_ch4_noncombustion_anthracite_air == Inf]<-0 -TIV_ch4_noncombustion_anthracite_air = as.vector(DIV_ch4_noncombustion_anthracite_air) %*% L - -write.csv(TIV_ch4_noncombustion_anthracite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_anthracite_air = as.vector(DIV_ch4_noncombustion_anthracite_air) * L -TIV_breakdown_ch4_noncombustion_anthracite_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_anthracite_air) -TIV_country_breakdown_ch4_noncombustion_anthracite_air_w_labels = t(TIV_breakdown_ch4_noncombustion_anthracite_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_anthracite_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_ixi.csv")) - -## bituminous coal -CH4_noncombustion_bituminouscoal_air = satellite[71,] -CH4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air*28 -DIV_ch4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air/total_output -DIV_ch4_noncombustion_bituminouscoal_air[is.na(DIV_ch4_noncombustion_bituminouscoal_air)]=0 -DIV_ch4_noncombustion_bituminouscoal_air[DIV_ch4_noncombustion_bituminouscoal_air == Inf]<-0 -TIV_ch4_noncombustion_bituminouscoal_air = as.vector(DIV_ch4_noncombustion_bituminouscoal_air) %*% L - -write.csv(TIV_ch4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_bituminouscoal_air = as.vector(DIV_ch4_noncombustion_bituminouscoal_air) * L -TIV_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_bituminouscoal_air) -TIV_country_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels = t(TIV_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_ixi.csv")) - -## coking coal -CH4_noncombustion_cokingcoal_air = satellite[72,] -CH4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air*28 -DIV_ch4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air/total_output -DIV_ch4_noncombustion_cokingcoal_air[is.na(DIV_ch4_noncombustion_cokingcoal_air)]=0 -DIV_ch4_noncombustion_cokingcoal_air[DIV_ch4_noncombustion_cokingcoal_air == Inf]<-0 -TIV_ch4_noncombustion_cokingcoal_air = as.vector(DIV_ch4_noncombustion_cokingcoal_air) %*% L - -write.csv(TIV_ch4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_cokingcoal_air = as.vector(DIV_ch4_noncombustion_cokingcoal_air) * L -TIV_breakdown_ch4_noncombustion_cokingcoal_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_cokingcoal_air) -TIV_country_breakdown_ch4_noncombustion_cokingcoal_air_w_labels = t(TIV_breakdown_ch4_noncombustion_cokingcoal_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_cokingcoal_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_ixi.csv")) - -## lignite -CH4_noncombustion_lignite_air = satellite[73,] -CH4_noncombustion_lignite_air = CH4_noncombustion_lignite_air*28 -DIV_ch4_noncombustion_lignite_air = CH4_noncombustion_lignite_air/total_output -DIV_ch4_noncombustion_lignite_air[is.na(DIV_ch4_noncombustion_lignite_air)]=0 -DIV_ch4_noncombustion_lignite_air[DIV_ch4_noncombustion_lignite_air == Inf]<-0 -TIV_ch4_noncombustion_lignite_air = as.vector(DIV_ch4_noncombustion_lignite_air) %*% L - -write.csv(TIV_ch4_noncombustion_lignite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_lignite_air = as.vector(DIV_ch4_noncombustion_lignite_air) * L -TIV_breakdown_ch4_noncombustion_lignite_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_lignite_air) -TIV_country_breakdown_ch4_noncombustion_lignite_air_w_labels = t(TIV_breakdown_ch4_noncombustion_lignite_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_lignite_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_ixi.csv")) - -## subbituminous coal -CH4_noncombustion_subbituminouscoal_air = satellite[74,] -CH4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air*28 -DIV_ch4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air/total_output -DIV_ch4_noncombustion_subbituminouscoal_air[is.na(DIV_ch4_noncombustion_subbituminouscoal_air)]=0 -DIV_ch4_noncombustion_subbituminouscoal_air[DIV_ch4_noncombustion_subbituminouscoal_air == Inf]<-0 -TIV_ch4_noncombustion_subbituminouscoal_air = as.vector(DIV_ch4_noncombustion_subbituminouscoal_air) %*% L - -write.csv(TIV_ch4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_subbituminouscoal_air = as.vector(DIV_ch4_noncombustion_subbituminouscoal_air) * L -TIV_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_subbituminouscoal_air) -TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels = t(TIV_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_ixi.csv")) - -## oil refinery -CH4_noncombustion_oilrefinery_air = satellite[75,] -CH4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air*28 -DIV_ch4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air/total_output -DIV_ch4_noncombustion_oilrefinery_air[is.na(DIV_ch4_noncombustion_oilrefinery_air)]=0 -DIV_ch4_noncombustion_oilrefinery_air[DIV_ch4_noncombustion_oilrefinery_air == Inf]<-0 -TIV_ch4_noncombustion_oilrefinery_air = as.vector(DIV_ch4_noncombustion_oilrefinery_air) %*% L - -write.csv(TIV_ch4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_noncombustion_oilrefinery_air = as.vector(DIV_ch4_noncombustion_oilrefinery_air) * L -TIV_breakdown_ch4_noncombustion_oilrefinery_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_noncombustion_oilrefinery_air) -TIV_country_breakdown_ch4_noncombustion_oilrefinery_air_w_labels = t(TIV_breakdown_ch4_noncombustion_oilrefinery_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_oilrefinery_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_ixi.csv")) - - -# CH4 agriculture air -CH4_agriculture_air = satellite[427,] -CH4_agriculture_air = CH4_agriculture_air*28 -DIV_ch4_agriculture_air = CH4_agriculture_air/total_output -DIV_ch4_agriculture_air[is.na(DIV_ch4_agriculture_air)]=0 -DIV_ch4_agriculture_air[DIV_ch4_agriculture_air == Inf]<-0 -TIV_ch4_agriculture_air = as.vector(DIV_ch4_agriculture_air) %*% L - -write.csv(TIV_ch4_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_agriculture_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_agriculture_air = as.vector(DIV_ch4_agriculture_air) * L -TIV_breakdown_ch4_agriculture_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_agriculture_air) -TIV_country_breakdown_ch4_agriculture_air_w_labels = t(TIV_breakdown_ch4_agriculture_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_agriculture_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_",year_current,"_ixi.csv")) - - -# CH4 waste air -CH4_waste_air = satellite[436,] -CH4_waste_air = CH4_waste_air*28 -DIV_ch4_waste_air = CH4_waste_air/total_output -DIV_ch4_waste_air[is.na(DIV_ch4_waste_air)]=0 -DIV_ch4_waste_air[DIV_ch4_waste_air == Inf]<-0 -TIV_ch4_waste_air = as.vector(DIV_ch4_waste_air) %*% L - -write.csv(TIV_ch4_waste_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_waste_air_",year_current,"_ixi.csv")) - -TIV_breakdown_ch4_waste_air = as.vector(DIV_ch4_waste_air) * L -TIV_breakdown_ch4_waste_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_ch4_waste_air) -TIV_country_breakdown_ch4_waste_air_w_labels = t(TIV_breakdown_ch4_waste_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_waste_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_",year_current,"_ixi.csv")) - - -# N2O combustion air -N2O_combustion_air = satellite[26,] -#write.csv(N2O_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/n2o_combustion_air_",year_current,"_ixi.csv")) -N2O_combustion_air = N2O_combustion_air*265 -#write.csv(N2O_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/n2o_CO2eq_combustion_air_",year_current,"_ixi.csv")) -DIV_n2o_combustion_air = N2O_combustion_air/total_output -DIV_n2o_combustion_air[is.na(DIV_n2o_combustion_air)]=0 -DIV_n2o_combustion_air[DIV_n2o_combustion_air == Inf]<-0 -#write.csv(DIV_n2o_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/DIV_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv")) -TIV_n2o_combustion_air = as.vector(DIV_n2o_combustion_air) %*% L - -write.csv(TIV_n2o_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv")) - -TIV_breakdown_n2o_combustion_air = as.vector(DIV_n2o_combustion_air) * L -TIV_breakdown_n2o_combustion_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_n2o_combustion_air) -TIV_country_breakdown_n2o_combustion_air_w_labels = t(TIV_breakdown_n2o_combustion_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_n2o_combustion_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv")) - - -# N2O agriculture air -N2O_agriculture_air = satellite[430,] -N2O_agriculture_air = N2O_agriculture_air*265 -DIV_n2o_agriculture_air = N2O_agriculture_air/total_output -DIV_n2o_agriculture_air[is.na(DIV_n2o_agriculture_air)]=0 -DIV_n2o_agriculture_air[DIV_n2o_agriculture_air == Inf]<-0 -TIV_n2o_agriculture_air = as.vector(DIV_n2o_agriculture_air) %*% L - -write.csv(TIV_n2o_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv")) - -TIV_breakdown_n2o_agriculture_air = as.vector(DIV_n2o_agriculture_air) * L -TIV_breakdown_n2o_agriculture_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_n2o_agriculture_air) -TIV_country_breakdown_n2o_agriculture_air_w_labels = t(TIV_breakdown_n2o_agriculture_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_n2o_agriculture_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv")) - - -# SF6 air -SF6_air = satellite[424,] -#write.csv(SF6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/sf6_air_",year_current,"_ixi.csv")) -SF6_air = SF6_air*23500 -#write.csv(SF6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/sf6_CO2eq_air_",year_current,"_ixi.csv")) -DIV_sf6_air = SF6_air/total_output -DIV_sf6_air[is.na(DIV_sf6_air)]=0 -DIV_sf6_air[DIV_sf6_air == Inf]<-0 -#write.csv(DIV_sf6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/DIV_sf6_CO2eq_air_",year_current,"_ixi.csv")) -TIV_sf6_air = as.vector(DIV_sf6_air) %*% L - -write.csv(TIV_sf6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_sf6_CO2eq_air_",year_current,"_ixi.csv")) - -TIV_breakdown_sf6_air = as.vector(DIV_sf6_air) * L -TIV_breakdown_sf6_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_sf6_air) -TIV_country_breakdown_sf6_air_w_labels = t(TIV_breakdown_sf6_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_sf6_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_ixi.csv")) - - -# HFC air -HFC_air = satellite[425,] -#write.csv(HFC_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/hfc_CO2eq_air_",year_current,"_ixi.csv")) -DIV_hfc_air = HFC_air/total_output -DIV_hfc_air[is.na(DIV_hfc_air)]=0 -DIV_hfc_air[DIV_hfc_air == Inf]<-0 -#write.csv(DIV_hfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/DIV_hfc_CO2eq_air_",year_current,"_ixi.csv")) -TIV_hfc_air = as.vector(DIV_hfc_air) %*% L - -write.csv(TIV_hfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_hfc_CO2eq_air_",year_current,"_ixi.csv")) - -TIV_breakdown_hfc_air = as.vector(DIV_hfc_air) * L -TIV_breakdown_hfc_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_hfc_air) -TIV_country_breakdown_hfc_air_w_labels = t(TIV_breakdown_hfc_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_hfc_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_ixi.csv")) - - -# PFC air -PFC_air = satellite[426,] -#write.csv(PFC_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/pfc_CO2eq_air_",year_current,"_ixi.csv")) -DIV_pfc_air = PFC_air/total_output -DIV_pfc_air[is.na(DIV_pfc_air)]=0 -DIV_pfc_air[DIV_pfc_air == Inf]<-0 -#write.csv(DIV_pfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/DIV_pfc_CO2eq_air_",year_current,"_ixi.csv")) -TIV_pfc_air = as.vector(DIV_pfc_air) %*% L - -write.csv(TIV_pfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_pfc_CO2eq_air_",year_current,"_ixi.csv")) - -TIV_breakdown_pfc_air = as.vector(DIV_pfc_air) * L -TIV_breakdown_pfc_air_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_pfc_air) -TIV_country_breakdown_pfc_air_w_labels = t(TIV_breakdown_pfc_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_pfc_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_ixi.csv")) - - -# energy carrier use -energy_carrier_use = satellite[470,] -write.csv(energy_carrier_use, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/satellite/energy_carrier_use_",year_current,"_ixi.csv")) -DIV_e_u = energy_carrier_use/total_output -DIV_e_u[is.na(DIV_e_u)]=0 -DIV_e_u[DIV_e_u == Inf]<-0 -TIV_e_u = as.vector(DIV_e_u) %*% L - -write.csv(TIV_e_u, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_energy_carrier_use_",year_current,"_ixi.csv")) - -TIV_breakdown_e_u = as.vector(DIV_e_u) * L -TIV_breakdown_e_u_w_labels = cbind(Exiobase_T_labels_ixi, TIV_breakdown_e_u) -TIV_country_breakdown_e_u_w_labels = t(TIV_breakdown_e_u_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_e_u_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_energy_carrier_use_",year_current,"_ixi.csv")) -} - - -# EXIOBASE_cluster_pxp_version - -years_exiobase_pxp = c(2005,2010) - -for (i in years_exiobase_pxp){ - -year_current = i - -A = read.delim(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/A.txt"),header = F) - -write.csv(A, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/A.csv")) - -A = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/A.csv",sep = ""),row.names=NULL,as.is=TRUE)[4:9803,4:9803] -A[is.na(A)]=0 -A = mapply(A, FUN = as.numeric) -A = matrix(data = A, ncol = 9800, nrow = 9800) - -L = solve(diag(dim(A)[1])-A) # this solves the Leontief inverse initially -L[is.na(L)]=0 - - -# final demand - -FD = read.delim(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/Y.txt"),header = F) - -write.csv(FD, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/Y.csv")) - - -Exiobase_T_labels_pxp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/Y.csv"))[4:9803,1:3] - -write.csv(Exiobase_T_labels_pxp, paste0(data_dir_exiobase, "/Exiobase_T_labels_pxp.csv")) - -Exiobase_FD_labels_pxp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/Y.csv"))[1:3,4:346] - -write.csv(Exiobase_FD_labels_pxp, paste0(data_dir_exiobase, "/Exiobase_FD_labels_pxp.csv")) - - -FD = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/Y.csv",sep=""),row.names=NULL,as.is=TRUE)[4:9803,4:346] -FD[is.na(FD)]=0 -FD = mapply(FD, FUN = as.numeric) -FD = matrix(data=FD,ncol=343,nrow=9800) - -write.csv(FD, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/FD_",year_current,"_pxp.csv")) - - -# total output -total_output = L %*% rowSums(FD) - -write.csv(total_output, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/total_output_",year_current,"_pxp.csv")) - - -# direct environmental vectors -satellite = read.delim(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/F.txt"),header = F) - -write.csv(satellite, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/F.csv")) - - -satellite = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/F.csv",sep=""),row.names=NULL,as.is=TRUE)[3:1106,3:9802] -satellite[is.na(satellite)]=0 -satellite = mapply(satellite, FUN = as.numeric) -satellite = matrix(data=satellite,ncol=9800,nrow=1104) - - -write.csv(satellite, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/satellite_",year_current,"_pxp.csv")) - - -# direct environmental vectors on final demand - -satellite_FD = read.delim(paste0(data_dir_exiobase, "/IOT_", year_current, "_pxp/satellite/F_hh.txt"),header = F) - -write.csv(satellite_FD, paste0(data_dir_exiobase, "/IOT_", year_current, "_pxp/satellite/F_hh.csv")) - - -# CO2 combustion air -CO2_combustion_air = satellite[24,] -#write.csv(CO2_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/co2_combustion_air_",year_current,"_pxp.csv")) -DIV_co2_combustion_air = CO2_combustion_air/total_output -DIV_co2_combustion_air[is.na(DIV_co2_combustion_air)]=0 -DIV_co2_combustion_air[DIV_co2_combustion_air == Inf]<-0 -#write.csv(DIV_co2_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_co2_combustion_air_",year_current,"_pxp.csv")) -TIV_co2_combustion_air = as.vector(DIV_co2_combustion_air) %*% L - -write.csv(TIV_co2_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_combustion_air_",year_current,"_pxp.csv")) - -TIV_breakdown_co2_combustion_air = as.vector(DIV_co2_combustion_air) * L -TIV_breakdown_co2_combustion_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_co2_combustion_air) -TIV_country_breakdown_co2_combustion_air_w_labels = t(TIV_breakdown_co2_combustion_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_combustion_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_combustion_air_",year_current,"_pxp.csv")) - - -# CO2 non-combustion air -## cement -CO2_noncombustion_cement_air = satellite[93,] -#saveRDS(CO2_noncombustion_cement_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/co2_noncombustion_cement_air_",year_current,".rds")) -DIV_co2_noncombustion_cement_air = CO2_noncombustion_cement_air/total_output -DIV_co2_noncombustion_cement_air[is.na(DIV_co2_noncombustion_cement_air)]=0 -DIV_co2_noncombustion_cement_air[DIV_co2_noncombustion_cement_air == Inf]<-0 -#saveRDS(DIV_co2_noncombustion_cement_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_co2_noncombustion_cement_air_",year_current,".rds")) -TIV_co2_noncombustion_cement_air = as.vector(DIV_co2_noncombustion_cement_air) %*% L - -write.csv(TIV_co2_noncombustion_cement_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_noncombustion_cement_air_",year_current,"_pxp.csv")) - -TIV_breakdown_co2_noncombustion_cement_air = as.vector(DIV_co2_noncombustion_cement_air) * L -TIV_breakdown_co2_noncombustion_cement_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_co2_noncombustion_cement_air) -TIV_country_breakdown_co2_noncombustion_cement_air_w_labels = t(TIV_breakdown_co2_noncombustion_cement_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_noncombustion_cement_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_pxp.csv")) - -## lime -CO2_noncombustion_lime_air = satellite[94,] -#saveRDS(CO2_noncombustion_lime_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/co2_noncombustion_lime_air_",year_current,".rds")) -DIV_co2_noncombustion_lime_air = CO2_noncombustion_lime_air/total_output -DIV_co2_noncombustion_lime_air[is.na(DIV_co2_noncombustion_lime_air)]=0 -DIV_co2_noncombustion_lime_air[DIV_co2_noncombustion_lime_air == Inf]<-0 -#saveRDS(DIV_co2_noncombustion_lime_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_co2_noncombustion_lime_air_",year_current,".rds")) -TIV_co2_noncombustion_lime_air = as.vector(DIV_co2_noncombustion_lime_air) %*% L - -write.csv(TIV_co2_noncombustion_lime_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_noncombustion_lime_air_",year_current,"_pxp.csv")) - -TIV_breakdown_co2_noncombustion_lime_air = as.vector(DIV_co2_noncombustion_lime_air) * L -TIV_breakdown_co2_noncombustion_lime_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_co2_noncombustion_lime_air) -TIV_country_breakdown_co2_noncombustion_lime_air_w_labels = t(TIV_breakdown_co2_noncombustion_lime_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_noncombustion_lime_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_pxp.csv")) - - -# CO2 agriculture peat decay air -CO2_agriculture_peatdecay_air = satellite[428,] -#saveRDS(CO2_agriculture_peatdecay_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/co2_agriculture_peatdecay_air_",year_current,".rds")) -DIV_co2_agriculture_peatdecay_air = CO2_agriculture_peatdecay_air/total_output -DIV_co2_agriculture_peatdecay_air[is.na(DIV_co2_agriculture_peatdecay_air)]=0 -DIV_co2_agriculture_peatdecay_air[DIV_co2_agriculture_peatdecay_air == Inf]<-0 -#saveRDS(DIV_co2_agriculture_peatdecay_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_co2_agriculture_peatdecay_air_",year_current,".rds")) -TIV_co2_agriculture_peatdecay_air = as.vector(DIV_co2_agriculture_peatdecay_air) %*% L - -write.csv(TIV_co2_agriculture_peatdecay_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_agriculture_peatdecay_air_",year_current,"_pxp.csv")) - -TIV_breakdown_co2_agriculture_peatdecay_air = as.vector(DIV_co2_agriculture_peatdecay_air) * L -TIV_breakdown_co2_agriculture_peatdecay_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_co2_agriculture_peatdecay_air) -TIV_country_breakdown_co2_agriculture_peatdecay_air_w_labels = t(TIV_breakdown_co2_agriculture_peatdecay_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_agriculture_peatdecay_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_pxp.csv")) - - -# CO2 waste air -## biogenic -CO2_waste_biogenic_air = satellite[438,] -#saveRDS(CO2_waste_biogenic_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/co2_waste_biogenic_air_",year_current,".rds")) -DIV_co2_waste_biogenic_air = CO2_waste_biogenic_air/total_output -DIV_co2_waste_biogenic_air[is.na(DIV_co2_waste_biogenic_air)]=0 -DIV_co2_waste_biogenic_air[DIV_co2_waste_biogenic_air == Inf]<-0 -#saveRDS(DIV_co2_waste_biogenic_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_co2_waste_biogenic_air_",year_current,".rds")) -TIV_co2_biogenic_air = as.vector(DIV_co2_waste_biogenic_air) %*% L - -write.csv(TIV_co2_biogenic_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_biogenic_air_",year_current,"_pxp.csv")) - -TIV_breakdown_co2_biogenic_air = as.vector(DIV_co2_waste_biogenic_air) * L -TIV_breakdown_co2_biogenic_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_co2_biogenic_air) -TIV_country_breakdown_co2_biogenic_air_w_labels = t(TIV_breakdown_co2_biogenic_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_biogenic_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_biogenic_air_",year_current,"_pxp.csv")) - -## fossil -CO2_waste_fossil_air = satellite[439,] -#saveRDS(CO2_waste_fossil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/co2_waste_fossil_air_",year_current,".rds")) -DIV_co2_waste_fossil_air = CO2_waste_fossil_air/total_output -DIV_co2_waste_fossil_air[is.na(DIV_co2_waste_fossil_air)]=0 -DIV_co2_waste_fossil_air[DIV_co2_waste_fossil_air == Inf]<-0 -#saveRDS(DIV_co2_waste_fossil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_co2_waste_fossil_air_",year_current,".rds")) -TIV_co2_waste_fossil_air = as.vector(DIV_co2_waste_fossil_air) %*% L - -write.csv(TIV_co2_waste_fossil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_waste_fossil_air_",year_current,"_pxp.csv")) - -TIV_breakdown_co2_waste_fossil_air = as.vector(DIV_co2_waste_fossil_air) * L -TIV_breakdown_co2_waste_fossil_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_co2_waste_fossil_air) -TIV_country_breakdown_co2_waste_fossil_air_w_labels = t(TIV_breakdown_co2_waste_fossil_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_co2_waste_fossil_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_pxp.csv")) - - -# CH4 combustion air -CH4_combustion_air = satellite[25,] -#saveRDS(CH4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_combustion_air_",year_current,".rds")) -CH4_combustion_air = CH4_combustion_air*28 -#saveRDS(CH4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_combustion_air_",year_current,".rds")) -DIV_ch4_combustion_air = CH4_combustion_air/total_output -DIV_ch4_combustion_air[is.na(DIV_ch4_combustion_air)]=0 -DIV_ch4_combustion_air[DIV_ch4_combustion_air == Inf]<-0 -#saveRDS(DIV_ch4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_combustion_air_",year_current,".rds")) -TIV_ch4_combustion_air = as.vector(DIV_ch4_combustion_air) %*% L - -#saveRDS(TIV_ch4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_combustion_air_",year_current,".rds")) -write.csv(TIV_ch4_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_combustion_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_combustion_air = as.vector(DIV_ch4_combustion_air) * L -TIV_breakdown_ch4_combustion_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_combustion_air) -TIV_country_breakdown_ch4_combustion_air_w_labels = t(TIV_breakdown_ch4_combustion_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_combustion_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_combustion_air_",year_current,"_pxp.csv")) - - -# CH4 non-combustion air -## gas -CH4_noncombustion_gas_air = satellite[68,] -#saveRDS(CH4_noncombustion_gas_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_gas_air_",year_current,".rds")) -CH4_noncombustion_gas_air = CH4_noncombustion_gas_air*28 -#saveRDS(CH4_noncombustion_gas_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_gas_air_",year_current,".rds")) -DIV_ch4_noncombustion_gas_air = CH4_noncombustion_gas_air/total_output -DIV_ch4_noncombustion_gas_air[is.na(DIV_ch4_noncombustion_gas_air)]=0 -DIV_ch4_noncombustion_gas_air[DIV_ch4_noncombustion_gas_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_gas_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_gas_air_",year_current,".rds")) -TIV_ch4_noncombustion_gas_air = as.vector(DIV_ch4_noncombustion_gas_air) %*% L - -write.csv(TIV_ch4_noncombustion_gas_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_gas_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_gas_air = as.vector(DIV_ch4_noncombustion_gas_air) * L -TIV_breakdown_ch4_noncombustion_gas_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_gas_air) -TIV_country_breakdown_ch4_noncombustion_gas_air_w_labels = t(TIV_breakdown_ch4_noncombustion_gas_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_gas_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_",year_current,"_pxp.csv")) - -## oil -CH4_noncombustion_oil_air = satellite[69,] -#saveRDS(CH4_noncombustion_oil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_oil_air_",year_current,".rds")) -CH4_noncombustion_oil_air = CH4_noncombustion_oil_air*28 -#saveRDS(CH4_noncombustion_oil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_oil_air_",year_current,".rds")) -DIV_ch4_noncombustion_oil_air = CH4_noncombustion_oil_air/total_output -DIV_ch4_noncombustion_oil_air[is.na(DIV_ch4_noncombustion_oil_air)]=0 -DIV_ch4_noncombustion_oil_air[DIV_ch4_noncombustion_oil_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_oil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_oil_air_",year_current,".rds")) -TIV_ch4_noncombustion_oil_air = as.vector(DIV_ch4_noncombustion_oil_air) %*% L - -write.csv(TIV_ch4_noncombustion_oil_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_oil_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_oil_air = as.vector(DIV_ch4_noncombustion_oil_air) * L -TIV_breakdown_ch4_noncombustion_oil_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_oil_air) -TIV_country_breakdown_ch4_noncombustion_oil_air_w_labels = t(TIV_breakdown_ch4_noncombustion_oil_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_oil_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_",year_current,"_pxp.csv")) - -## anthracite -CH4_noncombustion_anthracite_air = satellite[70,] -#saveRDS(CH4_noncombustion_anthracite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_anthracite_air_",year_current,".rds")) -CH4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air*28 -#saveRDS(CH4_noncombustion_anthracite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_anthracite_air_",year_current,".rds")) -DIV_ch4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air/total_output -DIV_ch4_noncombustion_anthracite_air[is.na(DIV_ch4_noncombustion_anthracite_air)]=0 -DIV_ch4_noncombustion_anthracite_air[DIV_ch4_noncombustion_anthracite_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_anthracite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_anthracite_air_",year_current,".rds")) -TIV_ch4_noncombustion_anthracite_air = as.vector(DIV_ch4_noncombustion_anthracite_air) %*% L - -write.csv(TIV_ch4_noncombustion_anthracite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_anthracite_air = as.vector(DIV_ch4_noncombustion_anthracite_air) * L -TIV_breakdown_ch4_noncombustion_anthracite_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_anthracite_air) -TIV_country_breakdown_ch4_noncombustion_anthracite_air_w_labels = t(TIV_breakdown_ch4_noncombustion_anthracite_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_anthracite_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_pxp.csv")) - -## bituminous coal -CH4_noncombustion_bituminouscoal_air = satellite[71,] -#saveRDS(CH4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_bituminouscoal_air_",year_current,".rds")) -CH4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air*28 -#saveRDS(CH4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,".rds")) -DIV_ch4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air/total_output -DIV_ch4_noncombustion_bituminouscoal_air[is.na(DIV_ch4_noncombustion_bituminouscoal_air)]=0 -DIV_ch4_noncombustion_bituminouscoal_air[DIV_ch4_noncombustion_bituminouscoal_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,".rds")) -TIV_ch4_noncombustion_bituminouscoal_air = as.vector(DIV_ch4_noncombustion_bituminouscoal_air) %*% L - -write.csv(TIV_ch4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_bituminouscoal_air = as.vector(DIV_ch4_noncombustion_bituminouscoal_air) * L -TIV_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_bituminouscoal_air) -TIV_country_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels = t(TIV_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_pxp.csv")) - -## coking coal -CH4_noncombustion_cokingcoal_air = satellite[72,] -#saveRDS(CH4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_cokingcoal_air_",year_current,".rds")) -CH4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air*28 -#saveRDS(CH4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,".rds")) -DIV_ch4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air/total_output -DIV_ch4_noncombustion_cokingcoal_air[is.na(DIV_ch4_noncombustion_cokingcoal_air)]=0 -DIV_ch4_noncombustion_cokingcoal_air[DIV_ch4_noncombustion_cokingcoal_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,".rds")) -TIV_ch4_noncombustion_cokingcoal_air = as.vector(DIV_ch4_noncombustion_cokingcoal_air) %*% L - -write.csv(TIV_ch4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_cokingcoal_air = as.vector(DIV_ch4_noncombustion_cokingcoal_air) * L -TIV_breakdown_ch4_noncombustion_cokingcoal_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_cokingcoal_air) -TIV_country_breakdown_ch4_noncombustion_cokingcoal_air_w_labels = t(TIV_breakdown_ch4_noncombustion_cokingcoal_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_cokingcoal_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_pxp.csv")) - -## lignite -CH4_noncombustion_lignite_air = satellite[73,] -#saveRDS(CH4_noncombustion_lignite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_lignite_air_",year_current,".rds")) -CH4_noncombustion_lignite_air = CH4_noncombustion_lignite_air*28 -#saveRDS(CH4_noncombustion_lignite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_lignite_air_",year_current,".rds")) -DIV_ch4_noncombustion_lignite_air = CH4_noncombustion_lignite_air/total_output -DIV_ch4_noncombustion_lignite_air[is.na(DIV_ch4_noncombustion_lignite_air)]=0 -DIV_ch4_noncombustion_lignite_air[DIV_ch4_noncombustion_lignite_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_lignite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_lignite_air_",year_current,".rds")) -TIV_ch4_noncombustion_lignite_air = as.vector(DIV_ch4_noncombustion_lignite_air) %*% L - -write.csv(TIV_ch4_noncombustion_lignite_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_lignite_air = as.vector(DIV_ch4_noncombustion_lignite_air) * L -TIV_breakdown_ch4_noncombustion_lignite_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_lignite_air) -TIV_country_breakdown_ch4_noncombustion_lignite_air_w_labels = t(TIV_breakdown_ch4_noncombustion_lignite_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_lignite_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_pxp.csv")) - -## subbituminous coal -CH4_noncombustion_subbituminouscoal_air = satellite[74,] -#saveRDS(CH4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_subbituminouscoal_air_",year_current,".rds")) -CH4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air*28 -#saveRDS(CH4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,".rds")) -DIV_ch4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air/total_output -DIV_ch4_noncombustion_subbituminouscoal_air[is.na(DIV_ch4_noncombustion_subbituminouscoal_air)]=0 -DIV_ch4_noncombustion_subbituminouscoal_air[DIV_ch4_noncombustion_subbituminouscoal_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,".rds")) -TIV_ch4_noncombustion_subbituminouscoal_air = as.vector(DIV_ch4_noncombustion_subbituminouscoal_air) %*% L - -write.csv(TIV_ch4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_subbituminouscoal_air = as.vector(DIV_ch4_noncombustion_subbituminouscoal_air) * L -TIV_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_subbituminouscoal_air) -TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels = t(TIV_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_pxp.csv")) - -## oil refinery -CH4_noncombustion_oilrefinery_air = satellite[75,] -#saveRDS(CH4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_noncombustion_oilrefinery_air_",year_current,".rds")) -CH4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air*28 -#saveRDS(CH4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,".rds")) -DIV_ch4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air/total_output -DIV_ch4_noncombustion_oilrefinery_air[is.na(DIV_ch4_noncombustion_oilrefinery_air)]=0 -DIV_ch4_noncombustion_oilrefinery_air[DIV_ch4_noncombustion_oilrefinery_air == Inf]<-0 -#saveRDS(DIV_ch4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,".rds")) -TIV_ch4_noncombustion_oilrefinery_air = as.vector(DIV_ch4_noncombustion_oilrefinery_air) %*% L - -write.csv(TIV_ch4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_noncombustion_oilrefinery_air = as.vector(DIV_ch4_noncombustion_oilrefinery_air) * L -TIV_breakdown_ch4_noncombustion_oilrefinery_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_noncombustion_oilrefinery_air) -TIV_country_breakdown_ch4_noncombustion_oilrefinery_air_w_labels = t(TIV_breakdown_ch4_noncombustion_oilrefinery_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_noncombustion_oilrefinery_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_pxp.csv")) - - -# CH4 agriculture air -CH4_agriculture_air = satellite[427,] -#saveRDS(CH4_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_agriculture_air_",year_current,".rds")) -CH4_agriculture_air = CH4_agriculture_air*28 -#saveRDS(CH4_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_agriculture_air_",year_current,".rds")) -DIV_ch4_agriculture_air = CH4_agriculture_air/total_output -DIV_ch4_agriculture_air[is.na(DIV_ch4_agriculture_air)]=0 -DIV_ch4_agriculture_air[DIV_ch4_agriculture_air == Inf]<-0 -#saveRDS(DIV_ch4_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_agriculture_air_",year_current,".rds")) -TIV_ch4_agriculture_air = as.vector(DIV_ch4_agriculture_air) %*% L - -write.csv(TIV_ch4_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_agriculture_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_agriculture_air = as.vector(DIV_ch4_agriculture_air) * L -TIV_breakdown_ch4_agriculture_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_agriculture_air) -TIV_country_breakdown_ch4_agriculture_air_w_labels = t(TIV_breakdown_ch4_agriculture_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_agriculture_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_agriculture_air_",year_current,"_pxp.csv")) - - -# CH4 waste air -CH4_waste_air = satellite[436,] -#saveRDS(CH4_waste_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_waste_air_",year_current,".rds")) -CH4_waste_air = CH4_waste_air*28 -#saveRDS(CH4_waste_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/ch4_CO2eq_waste_air_",year_current,".rds")) -DIV_ch4_waste_air = CH4_waste_air/total_output -DIV_ch4_waste_air[is.na(DIV_ch4_waste_air)]=0 -DIV_ch4_waste_air[DIV_ch4_waste_air == Inf]<-0 -#saveRDS(DIV_ch4_waste_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_ch4_CO2eq_waste_air_",year_current,".rds")) -TIV_ch4_waste_air = as.vector(DIV_ch4_waste_air) %*% L - -write.csv(TIV_ch4_waste_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_waste_air_",year_current,"_pxp.csv")) - -TIV_breakdown_ch4_waste_air = as.vector(DIV_ch4_waste_air) * L -TIV_breakdown_ch4_waste_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_ch4_waste_air) -TIV_country_breakdown_ch4_waste_air_w_labels = t(TIV_breakdown_ch4_waste_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_ch4_waste_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_waste_air_",year_current,"_pxp.csv")) - - -# N2O combustion air -N2O_combustion_air = satellite[26,] -#saveRDS(N2O_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/n2o_combustion_air_",year_current,".rds")) -N2O_combustion_air = N2O_combustion_air*265 -#saveRDS(N2O_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/n2o_CO2eq_combustion_air_",year_current,".rds")) -DIV_n2o_combustion_air = N2O_combustion_air/total_output -DIV_n2o_combustion_air[is.na(DIV_n2o_combustion_air)]=0 -DIV_n2o_combustion_air[DIV_n2o_combustion_air == Inf]<-0 -#saveRDS(DIV_n2o_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_n2o_CO2eq_combustion_air_",year_current,".rds")) -TIV_n2o_combustion_air = as.vector(DIV_n2o_combustion_air) %*% L - -#saveRDS(TIV_n2o_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_n2o_CO2eq_combustion_air_",year_current,".rds")) -write.csv(TIV_n2o_combustion_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_n2o_CO2eq_combustion_air_",year_current,"_pxp.csv")) - -TIV_breakdown_n2o_combustion_air = as.vector(DIV_n2o_combustion_air) * L -TIV_breakdown_n2o_combustion_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_n2o_combustion_air) -TIV_country_breakdown_n2o_combustion_air_w_labels = t(TIV_breakdown_n2o_combustion_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_n2o_combustion_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_pxp.csv")) - - -# N2O agriculture air -N2O_agriculture_air = satellite[430,] -#saveRDS(N2O_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/n2o_agriculture_air_",year_current,".rds")) -N2O_agriculture_air = N2O_agriculture_air*265 -#saveRDS(N2O_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/n2o_CO2eq_agriculture_air_",year_current,".rds")) -DIV_n2o_agriculture_air = N2O_agriculture_air/total_output -DIV_n2o_agriculture_air[is.na(DIV_n2o_agriculture_air)]=0 -DIV_n2o_agriculture_air[DIV_n2o_agriculture_air == Inf]<-0 -#saveRDS(DIV_n2o_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_n2o_CO2eq_agriculture_air_",year_current,".rds")) -TIV_n2o_agriculture_air = as.vector(DIV_n2o_agriculture_air) %*% L - -write.csv(TIV_n2o_agriculture_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_n2o_CO2eq_agriculture_air_",year_current,"_pxp.csv")) - -TIV_breakdown_n2o_agriculture_air = as.vector(DIV_n2o_agriculture_air) * L -TIV_breakdown_n2o_agriculture_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_n2o_agriculture_air) -TIV_country_breakdown_n2o_agriculture_air_w_labels = t(TIV_breakdown_n2o_agriculture_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_n2o_agriculture_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_pxp.csv")) - - -# SF6 air -SF6_air = satellite[424,] -#write.csv(SF6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/sf6_air_",year_current,"_pxp.csv")) -SF6_air = SF6_air*23500 -#write.csv(SF6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/sf6_CO2eq_air_",year_current,"_pxp.csv")) -DIV_sf6_air = SF6_air/total_output -DIV_sf6_air[is.na(DIV_sf6_air)]=0 -DIV_sf6_air[DIV_sf6_air == Inf]<-0 -#write.csv(DIV_sf6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_sf6_CO2eq_air_",year_current,"_pxp.csv")) -TIV_sf6_air = as.vector(DIV_sf6_air) %*% L - -write.csv(TIV_sf6_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_sf6_CO2eq_air_",year_current,"_pxp.csv")) - -TIV_breakdown_sf6_air = as.vector(DIV_sf6_air) * L -TIV_breakdown_sf6_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_sf6_air) -TIV_country_breakdown_sf6_air_w_labels = t(TIV_breakdown_sf6_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_sf6_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_pxp.csv")) - - -# HFC air -HFC_air = satellite[425,] -#write.csv(HFC_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/hfc_CO2eq_air_",year_current,"_pxp.csv")) -DIV_hfc_air = HFC_air/total_output -DIV_hfc_air[is.na(DIV_hfc_air)]=0 -DIV_hfc_air[DIV_hfc_air == Inf]<-0 -#write.csv(DIV_hfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_hfc_CO2eq_air_",year_current,"_pxp.csv")) -TIV_hfc_air = as.vector(DIV_hfc_air) %*% L - -write.csv(TIV_hfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_hfc_CO2eq_air_",year_current,"_pxp.csv")) - -TIV_breakdown_hfc_air = as.vector(DIV_hfc_air) * L -TIV_breakdown_hfc_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_hfc_air) -TIV_country_breakdown_hfc_air_w_labels = t(TIV_breakdown_hfc_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_hfc_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_pxp.csv")) - - -# PFC air -PFC_air = satellite[426,] -#write.csv(PFC_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/satellite/pfc_CO2eq_air_",year_current,"_pxp.csv")) -DIV_pfc_air = PFC_air/total_output -DIV_pfc_air[is.na(DIV_pfc_air)]=0 -DIV_pfc_air[DIV_pfc_air == Inf]<-0 -#write.csv(DIV_pfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/DIV_pfc_CO2eq_air_",year_current,"_pxp.csv")) -TIV_pfc_air = as.vector(DIV_pfc_air) %*% L - -write.csv(TIV_pfc_air, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_pfc_CO2eq_air_",year_current,"_pxp.csv")) - -TIV_breakdown_pfc_air = as.vector(DIV_pfc_air) * L -TIV_breakdown_pfc_air_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_pfc_air) -TIV_country_breakdown_pfc_air_w_labels = t(TIV_breakdown_pfc_air_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_pfc_air_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_pxp.csv")) - - -# energy carrier use -energy_carrier_use = satellite[470,] -DIV_e_u = energy_carrier_use/total_output -DIV_e_u[is.na(DIV_e_u)]=0 -DIV_e_u[DIV_e_u == Inf]<-0 -TIV_e_u = as.vector(DIV_e_u) %*% L - -#saveRDS(TIV_e_u, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_energy_carrier_use_",year_current,".rds")) -write.csv(TIV_e_u, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_energy_carrier_use_",year_current,"_pxp.csv")) - -TIV_breakdown_e_u = as.vector(DIV_e_u) * L -TIV_breakdown_e_u_w_labels = cbind(Exiobase_T_labels_pxp, TIV_breakdown_e_u) -TIV_country_breakdown_e_u_w_labels = t(TIV_breakdown_e_u_w_labels %>% - group_by(V1) %>% - select(-X,-V2) %>% - summarise_all(funs(sum))) - -write.csv(TIV_country_breakdown_e_u_w_labels, paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_energy_carrier_use_",year_current,"_pxp.csv")) -}</code></pre> </div> <div id="isf" class="section level1"> <h1>isf</h1> -<pre class="r"><code># income-stratified-footprints directory -data_dir_income_stratified_footprints = paste("/",file.path("data","metab","income-stratified-footprints", fsep=.Platform$file.sep),sep="") - - -################################################### !!!! method 1 - PPS HH - RENT NOT MAPPED TO EXIOBASE !!!! ########################################### -########################################################################################################################################################## -########################################################################################################################################################## - -#### IF YOU WANT THE RESULTS USING PPS PER ADULT EQUIVALENT - FILTER 'MEAN EXPENDITURE BY QUINTILE' BELOW FOR (unit == "PPS_AE") AND MAKE SURE TO UNCOMMENT -#### THE LINE SAVING IT AT THE END (AND COMMENT OUT THE LINE SAVING THE 'PPS HH' VERSION) - for both ixi and pxp Exiobase versions - -## Eurostat Household Budget Survey - -# load 'mean expenditure by quintile' data -hbs_exp_t133 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/hbs_exp_t133.csv")) -# rename and arrange by country -mean_expenditure_by_quintile = hbs_exp_t133 %>% - rename(geo = 3, quintile = "quantile") %>% - arrange(geo) - -# load 'mean expenditure by quintile and coicop' data -hbs_str_t223 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/hbs_str_t223.csv")) -# rename and arrange by country -mean_expenditure_by_coicop_sector = hbs_str_t223 %>% - rename(geo = 4, quintile = "quantile") %>% - arrange(geo) - -# create long data set -mean_expenditure_by_quintile_long = mean_expenditure_by_quintile %>% - filter(!(quintile %in% c("UNK","TOTAL"))) %>% - filter(!(geo %in% c("EA", - "EA12", - "EA13", - "EA17", - "EA18", - "EA19", - "EEA28", - "EEA30_2007", - "EFTA", - "EU15", - "EU25", - "EU27_2007", - "EU27_2020", - "EU28"))) %>% - gather(year,pps,-quintile,-unit,-geo) %>% - rename(mean_expenditure = pps) - -write_csv(mean_expenditure_by_quintile_long, paste0(data_dir_income_stratified_footprints, "/mean_expenditure_by_quintile_long.csv")) - -# create long data sets for both -mean_expenditure_by_quintile_long = mean_expenditure_by_quintile %>% - filter(unit == "PPS_HH") %>% # filter 'mean expenditure by quintile' in PPS per HouseHold - filter(!(quintile %in% c("UNK","TOTAL"))) %>% # filter out unknown and total expenditure - select(-unit) %>% - gather(year,pps,-quintile,-geo) - -mean_expenditure_by_coicop_sector_long = mean_expenditure_by_coicop_sector %>% - filter(!(quintile %in% c("UNK","TOTAL"))) %>% # filter out unknown and total expenditure - select(-unit) %>% - gather(year,pm,-quintile,-coicop,-geo) %>% - mutate(coicop = dplyr::recode(coicop, "CP041" = "rent", - "CP042" = "rent")) %>% - group_by(geo,quintile,coicop,year) %>% - mutate(pm = parse_number(pm), - pm = as.numeric(pm)) %>% - summarise(pm = sum(pm, na.rm = TRUE)) %>% - ungroup() %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE1" & - coicop == "CP072", 92-21-14,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE2" & - coicop == "CP072", 108-22-12,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE3" & - coicop == "CP072", 124-32-11,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE4" & - coicop == "CP072", 133-43-10,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE5" & - coicop == "CP072", 162-81-11,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE1" & - coicop == "CP044", 412-4-78-322,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE2" & - coicop == "CP044", 355-5-68-265,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE3" & - coicop == "CP044", 325-8-64-229,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE4" & - coicop == "CP044", 300-9-58-204,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE5" & - coicop == "CP044", 249-10-46-167,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE1" & - coicop == "CP044", 433-3-82-340,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE2" & - coicop == "CP044", 376-6-70-284,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE3" & - coicop == "CP044", 351-9-67-251,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE4" & - coicop == "CP044", 326-10-61-228,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE5" & - coicop == "CP044", 280-9-49-195,pm)) -## In the code above, I collapse (sum) the two 'rent' HBS sectors 'CP041' and 'CP042' to create a -## single 'rent' sector so as to allocate all rent to 'Real-estate services' in Exiobase. - - -# join the HBS expenditure tables together -join_expenditures = mean_expenditure_by_coicop_sector_long %>% - left_join(mean_expenditure_by_quintile_long, by = c("geo","quintile","year")) %>% - mutate(pps = as.numeric(pps), - pm = as.numeric(pm), - pps_coicop = pm*(pps/1000)) - - - -################################################### !!!! method 1 - IXI version - PPS HH NO RENT !!!! #################################################### -########################################################################################################################################################## -########################################################################################################################################################## - -## Exiobase - ixi version - -years_exb_ixi = c(2005,2010,2015) - -disaggregated_final_demand = NULL - -TIVs = NULL - -domestic_TIVs = NULL - -europe_TIVs = NULL - -national_fp = NULL - -national_territorial = NULL - -for (i in years_exb_ixi){ - year_current = i - - Exiobase_FD = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/FD_",year_current,"_ixi.csv"))[,-1] - - # select household final demand vectors for study countries - - AT = Exiobase_FD[,1] - BE = Exiobase_FD[,8] - BG = Exiobase_FD[,15] - CY = Exiobase_FD[,22] - CZ = Exiobase_FD[,29] - DE = Exiobase_FD[,36] - DK = Exiobase_FD[,43] - EE = Exiobase_FD[,50] - EL = Exiobase_FD[,78] - ES = Exiobase_FD[,57] - FI = Exiobase_FD[,64] - FR = Exiobase_FD[,71] - HR = Exiobase_FD[,85] - HU = Exiobase_FD[,92] - IE = Exiobase_FD[,99] - IT = Exiobase_FD[,106] - LT = Exiobase_FD[,113] - LU = Exiobase_FD[,120] - LV = Exiobase_FD[,127] - MT = Exiobase_FD[,134] - NL = Exiobase_FD[,141] - NO = Exiobase_FD[,288] - PL = Exiobase_FD[,148] - PT = Exiobase_FD[,155] - RO = Exiobase_FD[,162] - SE = Exiobase_FD[,169] - SI = Exiobase_FD[,176] - SK = Exiobase_FD[,183] - TR = Exiobase_FD[,274] - UK = Exiobase_FD[,190] - - Eurostat_countries = cbind(AT,BE,BG,CY,CZ,DE,DK,EE,EL,ES,FI,FR,HR,HU,IE,IT,LT,LU,LV,MT,NL,NO,PL,PT,RO,SE,SI,SK,TR,UK) - - # labels - - Exiobase_T_labels = read.csv(paste0(data_dir_income_stratified_footprints, "/data/Exiobase_T_labels_ixi_w_coicop_mapping_no_rent.csv")) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - - # hh fd with production sector labels - - hh_fd_with_production_sector_labels = cbind(Exiobase_T_labels,Eurostat_countries) %>% rename(geo = V1, sector = V2) - - # assumption of same purchase structure between quintiles of domestic and foreign final demand - - # replicate each cell of each country's hh final demand as many times as there are income groups in the HBS data - in this preliminary case:5 - - cells_repeat = data.frame(hh_fd_with_production_sector_labels %>% slice(rep(1:n(), each = 5))) - - quintiles = data.frame(rep(c("QUINTILE1","QUINTILE2","QUINTILE3","QUINTILE4","QUINTILE5"),163)) %>% rename_at(1,~"quintile") - - replicated = cbind(cells_repeat,quintiles) %>% rename(country_of_production = geo) - - # make fd data long - - replicated_long = replicated %>% gather(geo, value,-sector,-coicop,-quintile,-five_sectors,-country_of_production) - - year = as.character(rep(year_current,nrow(replicated_long))) - - replicated_long = cbind(year,replicated_long) - - - disaggregated_final_demand = rbind(disaggregated_final_demand, replicated_long) - - - # TIVs - - # CO2 - combustion - air - - Exiobase_TIV_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_combustion_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_combustion_air_", year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_domestic) - - Exiobase_TIV_europe_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_combustion_air_", year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_europe,TIV_CO2_not_europe) - - # CO2 - noncombustion - cement - air - - Exiobase_TIV_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_noncombustion_cement_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_noncombustion_cement_domestic) - - Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_noncombustion_cement_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_noncombustion_cement_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_noncombustion_cement_europe,TIV_CO2_noncombustion_cement_not_europe) - - # CO2 - noncombustion - lime - air - - Exiobase_TIV_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_noncombustion_lime_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_noncombustion_lime_domestic) - - Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_noncombustion_lime_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_noncombustion_lime_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_noncombustion_lime_europe,TIV_CO2_noncombustion_lime_not_europe) - - # CO2 - agriculture - peat decay - air - - Exiobase_TIV_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_agriculture_peatdecay_domestic) - - Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_agriculture_peatdecay_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_agriculture_peatdecay_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_agriculture_peatdecay_europe,TIV_CO2_agriculture_peatdecay_not_europe) - - # CO2 - waste - biogenic - air - - Exiobase_TIV_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_biogenic_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_biogenic_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_waste_biogenic_domestic) - - Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_biogenic_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_waste_biogenic_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_waste_biogenic_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_waste_biogenic_europe,TIV_CO2_waste_biogenic_not_europe) - - # CO2 - waste - fossil - air - - Exiobase_TIV_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_waste_fossil_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_waste_fossil_domestic) - - Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_waste_fossil_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_waste_fossil_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_waste_fossil_europe,TIV_CO2_waste_fossil_not_europe) - - - - # CH4 - combustion -air - - Exiobase_TIV_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_domestic) - - Exiobase_TIV_europe_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_europe,TIV_CH4_not_europe) - - # CH4 - noncombustion - gas - air - - Exiobase_TIV_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_gas_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_gas_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_gas_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_gas_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_gas_europe,TIV_CH4_noncombustion_gas_not_europe) - - # CH4 - noncombustion - oil - air - - Exiobase_TIV_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_oil_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_oil_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_oil_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_oil_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_oil_europe,TIV_CH4_noncombustion_oil_not_europe) - - # CH4 - noncombustion - anthracite - air - - Exiobase_TIV_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_anthracite_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_anthracite_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_anthracite_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_anthracite_europe,TIV_CH4_noncombustion_anthracite_not_europe) - - # CH4 - noncombustion - bituminouscoal - air - - Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_bituminouscoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_bituminouscoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_bituminouscoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_bituminouscoal_europe,TIV_CH4_noncombustion_bituminouscoal_not_europe) - - # CH4 - noncombustion - cokingcoal - air - - Exiobase_TIV_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_cokingcoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_cokingcoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_cokingcoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_cokingcoal_europe,TIV_CH4_noncombustion_cokingcoal_not_europe) - - # CH4 - noncombustion - lignite - air - - Exiobase_TIV_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_lignite_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_lignite_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_lignite_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_lignite_europe,TIV_CH4_noncombustion_lignite_not_europe) - - # CH4 - noncombustion - subbituminouscoal - air - - Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_subbituminouscoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_subbituminouscoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_subbituminouscoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_subbituminouscoal_europe,TIV_CH4_noncombustion_subbituminouscoal_not_europe) - - # CH4 - noncombustion - oilrefinery - air - - Exiobase_TIV_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_oilrefinery_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_oilrefinery_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_oilrefinery_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_oilrefinery_europe,TIV_CH4_noncombustion_oilrefinery_not_europe) - - # CH4 - agriculture - air - - Exiobase_TIV_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_agriculture_domestic) - - Exiobase_TIV_europe_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_agriculture_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_agriculture_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_agriculture_europe,TIV_CH4_agriculture_not_europe) - - # CH4 - waste - air - - Exiobase_TIV_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_waste_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_waste_domestic) - - Exiobase_TIV_europe_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_waste_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_waste_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_waste_europe,TIV_CH4_waste_not_europe) - - - # N2O - combustion - air - - Exiobase_TIV_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_N2O_domestic) - - Exiobase_TIV_europe_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_N2O_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_N2O_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_N2O_europe,TIV_N2O_not_europe) - - # N2O - agriculture - air - - Exiobase_TIV_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_N2O_agriculture_domestic) - - Exiobase_TIV_europe_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_N2O_agriculture_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_N2O_agriculture_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_N2O_agriculture_europe,TIV_N2O_agriculture_not_europe) - - # SF6 - air - - Exiobase_TIV_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_sf6_CO2eq_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_SF6_domestic) - - Exiobase_TIV_europe_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_SF6_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_SF6_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_SF6_europe,TIV_SF6_not_europe) - - # HFC - air - - Exiobase_TIV_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_hfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_HFC_domestic) - - Exiobase_TIV_europe_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_HFC_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_HFC_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_HFC_europe,TIV_HFC_not_europe) - - # PFC - air - - Exiobase_TIV_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_pfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_PFC_domestic) - - Exiobase_TIV_europe_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_PFC_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_PFC_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_PFC_europe,TIV_PFC_not_europe) - - # Energy use - - Exiobase_TIV_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_energy_carrier_use_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_energy_carrier_use_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_energy_domestic) - - Exiobase_TIV_europe_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_energy_carrier_use_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_energy_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_energy_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_energy_europe,TIV_energy_not_europe) - - # biomass - - Exiobase_TIV_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_biomass_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_biomass_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_biomass_domestic) - - Exiobase_TIV_europe_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_biomass_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_biomass_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_biomass_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_biomass_europe,TIV_biomass_not_europe) - - # construction materials - - Exiobase_TIV_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_const_materials_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_const_materials_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_const_materials_domestic) - - Exiobase_TIV_europe_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_const_materials_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_const_materials_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_const_materials_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_const_materials_europe,TIV_const_materials_not_europe) - - # fossil fuels - - Exiobase_TIV_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ffuels_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ffuels_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_ffuels_domestic) - - Exiobase_TIV_europe_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ffuels_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_ffuels_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_ffuels_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_ffuels_europe,TIV_ffuels_not_europe) - - # ores - - Exiobase_TIV_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ores_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ores_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_ores_domestic) - - Exiobase_TIV_europe_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ores_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_ores_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_ores_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_ores_europe,TIV_ores_not_europe) - - # cropland - - Exiobase_TIV_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_cropland_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_cropland_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_cropland_domestic) - - Exiobase_TIV_europe_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_cropland_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_cropland_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_cropland_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_cropland_europe,TIV_cropland_not_europe) - - # forest land - - Exiobase_TIV_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_forest_land_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_forest_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_forest_land_domestic) - - Exiobase_TIV_europe_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_forest_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_forest_land_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_forest_land_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_forest_land_europe,TIV_forest_land_not_europe) - - # pasture land - - Exiobase_TIV_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_pasture_land_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pasture_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_pasture_land_domestic) - - Exiobase_TIV_europe_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pasture_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_pasture_land_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_pasture_land_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_pasture_land_europe,TIV_pasture_land_not_europe) - - - # join with labels - - TIV_with_labels = cbind(Exiobase_T_labels, - t(Exiobase_TIV_co2_bp), - t(Exiobase_TIV_co2_noncombustion_cement_bp), - t(Exiobase_TIV_co2_noncombustion_lime_bp), - t(Exiobase_TIV_co2_agriculture_peatdecay_bp), - t(Exiobase_TIV_co2_waste_biogenic_bp), - t(Exiobase_TIV_co2_waste_fossil_bp), - t(Exiobase_TIV_ch4_bp), - t(Exiobase_TIV_ch4_noncombustion_gas_bp), - t(Exiobase_TIV_ch4_noncombustion_oil_bp), - t(Exiobase_TIV_ch4_noncombustion_anthracite_bp), - t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp), - t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp), - t(Exiobase_TIV_ch4_noncombustion_lignite_bp), - t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp), - t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp), - t(Exiobase_TIV_ch4_agriculture_bp), - t(Exiobase_TIV_ch4_waste_bp), - t(Exiobase_TIV_n2o_bp), - t(Exiobase_TIV_n2o_agriculture_bp), - t(Exiobase_TIV_sf6_bp), - t(Exiobase_TIV_hfc_bp), - t(Exiobase_TIV_pfc_bp), - t(Exiobase_TIV_energy_use_bp), - t(Exiobase_TIV_biomass_bp), - t(Exiobase_TIV_const_materials_bp), - t(Exiobase_TIV_ffuels_bp), - t(Exiobase_TIV_ores_bp), - t(Exiobase_TIV_cropland_bp), - t(Exiobase_TIV_forest_land_bp), - t(Exiobase_TIV_pasture_land_bp)) %>% - rename(TIV_CO2 = "t(Exiobase_TIV_co2_bp)", - TIV_CO2_noncombustion_cement = "t(Exiobase_TIV_co2_noncombustion_cement_bp)", - TIV_CO2_noncombustion_lime = "t(Exiobase_TIV_co2_noncombustion_lime_bp)", - TIV_CO2_agriculture_peatdecay = "t(Exiobase_TIV_co2_agriculture_peatdecay_bp)", - TIV_CO2_waste_biogenic = "t(Exiobase_TIV_co2_waste_biogenic_bp)", - TIV_CO2_waste_fossil = "t(Exiobase_TIV_co2_waste_fossil_bp)", - TIV_CH4 = "t(Exiobase_TIV_ch4_bp)", - TIV_CH4_noncombustion_gas = "t(Exiobase_TIV_ch4_noncombustion_gas_bp)", - TIV_CH4_noncombustion_oil = "t(Exiobase_TIV_ch4_noncombustion_oil_bp)", - TIV_CH4_noncombustion_anthracite = "t(Exiobase_TIV_ch4_noncombustion_anthracite_bp)", - TIV_CH4_noncombustion_bituminouscoal = "t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp)", - TIV_CH4_noncombustion_cokingcoal = "t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp)", - TIV_CH4_noncombustion_lignite = "t(Exiobase_TIV_ch4_noncombustion_lignite_bp)", - TIV_CH4_noncombustion_subbituminouscoal = "t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp)", - TIV_CH4_noncombustion_oilrefinery = "t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp)", - TIV_CH4_agriculture = "t(Exiobase_TIV_ch4_agriculture_bp)", - TIV_CH4_waste = "t(Exiobase_TIV_ch4_waste_bp)", - TIV_N2O = "t(Exiobase_TIV_n2o_bp)", - TIV_N2O_agriculture = "t(Exiobase_TIV_n2o_agriculture_bp)", - TIV_SF6 = "t(Exiobase_TIV_sf6_bp)", - TIV_HFC = "t(Exiobase_TIV_hfc_bp)", - TIV_PFC = "t(Exiobase_TIV_pfc_bp)", - TIV_energy = "t(Exiobase_TIV_energy_use_bp)", - TIV_biomass = "t(Exiobase_TIV_biomass_bp)", - TIV_const_materials = "t(Exiobase_TIV_const_materials_bp)", - TIV_ffuels = "t(Exiobase_TIV_ffuels_bp)", - TIV_ores = "t(Exiobase_TIV_ores_bp)", - TIV_cropland = "t(Exiobase_TIV_cropland_bp)", - TIV_forest_land = "t(Exiobase_TIV_forest_land_bp)", - TIV_pasture_land = "t(Exiobase_TIV_pasture_land_bp)") %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year = as.character(rep(year_current,nrow(TIV_with_labels))) - - look = cbind(year,TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2) - - - - TIVs = rbind(TIVs,look) - - - # join domestic_TIVs with labels - - domestic_TIV_with_labels = cbind(Exiobase_T_labels, - Exiobase_TIV_country_breakdown_co2_bp, - Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_waste_fossil_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_agriculture_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_waste_bp %>% select(-country), - Exiobase_TIV_country_breakdown_n2o_bp %>% select(-country), - Exiobase_TIV_country_breakdown_n2o_agriculture_bp %>% select(-country), - Exiobase_TIV_country_breakdown_sf6_bp %>% select(-country), - Exiobase_TIV_country_breakdown_hfc_bp %>% select(-country), - Exiobase_TIV_country_breakdown_pfc_bp %>% select(-country), - Exiobase_TIV_country_breakdown_energy_use_bp %>% select(-country), - Exiobase_TIV_country_breakdown_biomass_bp %>% select(-country), - Exiobase_TIV_country_breakdown_const_materials_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ffuels_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ores_bp %>% select(-country), - Exiobase_TIV_country_breakdown_cropland_bp %>% select(-country), - Exiobase_TIV_country_breakdown_forest_land_bp %>% select(-country), - Exiobase_TIV_country_breakdown_pasture_land_bp %>% select(-country)) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK"), - country = dplyr::recode(country, "GR" = "EL", "GB" = "UK")) - - year_domestic = as.character(rep(year_current,nrow(domestic_TIV_with_labels))) - - look_domestic = cbind(year_domestic,domestic_TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2, geo = country, year = year_domestic) %>% - mutate(TIV_CO2_domestic = as.numeric(TIV_CO2_domestic), - TIV_CO2_noncombustion_cement_domestic = as.numeric(TIV_CO2_noncombustion_cement_domestic), - TIV_CO2_noncombustion_lime_domestic = as.numeric(TIV_CO2_noncombustion_lime_domestic), - TIV_CO2_agriculture_peatdecay_domestic = as.numeric(TIV_CO2_agriculture_peatdecay_domestic), - TIV_CO2_waste_biogenic_domestic = as.numeric(TIV_CO2_waste_biogenic_domestic), - TIV_CO2_waste_fossil_domestic = as.numeric(TIV_CO2_waste_fossil_domestic), - TIV_CH4_domestic = as.numeric(TIV_CH4_domestic), - TIV_CH4_noncombustion_gas_domestic = as.numeric(TIV_CH4_noncombustion_gas_domestic), - TIV_CH4_noncombustion_oil_domestic = as.numeric(TIV_CH4_noncombustion_oil_domestic), - TIV_CH4_noncombustion_anthracite_domestic = as.numeric(TIV_CH4_noncombustion_anthracite_domestic), - TIV_CH4_noncombustion_bituminouscoal_domestic = as.numeric(TIV_CH4_noncombustion_bituminouscoal_domestic), - TIV_CH4_noncombustion_cokingcoal_domestic = as.numeric(TIV_CH4_noncombustion_cokingcoal_domestic), - TIV_CH4_noncombustion_lignite_domestic = as.numeric(TIV_CH4_noncombustion_lignite_domestic), - TIV_CH4_noncombustion_subbituminouscoal_domestic = as.numeric(TIV_CH4_noncombustion_subbituminouscoal_domestic), - TIV_CH4_noncombustion_oilrefinery_domestic = as.numeric(TIV_CH4_noncombustion_oilrefinery_domestic), - TIV_CH4_agriculture_domestic = as.numeric(TIV_CH4_agriculture_domestic), - TIV_CH4_waste_domestic = as.numeric(TIV_CH4_waste_domestic), - TIV_N2O_domestic = as.numeric(TIV_N2O_domestic), - TIV_N2O_agriculture_domestic = as.numeric(TIV_N2O_agriculture_domestic), - TIV_SF6_domestic = as.numeric(TIV_SF6_domestic), - TIV_HFC_domestic = as.numeric(TIV_HFC_domestic), - TIV_PFC_domestic = as.numeric(TIV_PFC_domestic), - TIV_energy_domestic = as.numeric(TIV_energy_domestic), - TIV_biomass_domestic = as.numeric(TIV_biomass_domestic), - TIV_const_materials_domestic = as.numeric(TIV_const_materials_domestic), - TIV_ffuels_domestic = as.numeric(TIV_ffuels_domestic), - TIV_ores_domestic = as.numeric(TIV_ores_domestic), - TIV_cropland_domestic = as.numeric(TIV_cropland_domestic), - TIV_forest_land_domestic = as.numeric(TIV_forest_land_domestic), - TIV_pasture_land_domestic = as.numeric(TIV_pasture_land_domestic)) - - domestic_TIVs = rbind(domestic_TIVs, look_domestic) - - # european TIVs with labels - - europe_TIV_with_labels = cbind(Exiobase_T_labels, - Exiobase_TIV_europe_breakdown_co2_bp, - Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp, - Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp, - Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp, - Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp, - Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp, - Exiobase_TIV_europe_breakdown_ch4_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp, - Exiobase_TIV_europe_breakdown_ch4_agriculture_bp, - Exiobase_TIV_europe_breakdown_ch4_waste_bp, - Exiobase_TIV_europe_breakdown_n2o_bp, - Exiobase_TIV_europe_breakdown_n2o_agriculture_bp, - Exiobase_TIV_europe_breakdown_sf6_bp, - Exiobase_TIV_europe_breakdown_hfc_bp, - Exiobase_TIV_europe_breakdown_pfc_bp, - Exiobase_TIV_europe_breakdown_energy_use_bp, - Exiobase_TIV_europe_breakdown_biomass_bp, - Exiobase_TIV_europe_breakdown_const_materials_bp, - Exiobase_TIV_europe_breakdown_ffuels_bp, - Exiobase_TIV_europe_breakdown_ores_bp, - Exiobase_TIV_europe_breakdown_cropland_bp, - Exiobase_TIV_europe_breakdown_forest_land_bp, - Exiobase_TIV_europe_breakdown_pasture_land_bp) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year_europe = as.character(rep(year_current,nrow(europe_TIV_with_labels))) - - look_europe = cbind(year_europe,europe_TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2, year = year_europe) %>% - mutate(TIV_CO2_europe = as.numeric(TIV_CO2_europe), - TIV_CO2_noncombustion_cement_europe = as.numeric(TIV_CO2_noncombustion_cement_europe), - TIV_CO2_noncombustion_lime_europe = as.numeric(TIV_CO2_noncombustion_lime_europe), - TIV_CO2_agriculture_peatdecay_europe = as.numeric(TIV_CO2_agriculture_peatdecay_europe), - TIV_CO2_waste_biogenic_europe = as.numeric(TIV_CO2_waste_biogenic_europe), - TIV_CO2_waste_fossil_europe = as.numeric(TIV_CO2_waste_fossil_europe), - TIV_CH4_europe = as.numeric(TIV_CH4_europe), - TIV_CH4_noncombustion_gas_europe = as.numeric(TIV_CH4_noncombustion_gas_europe), - TIV_CH4_noncombustion_oil_europe = as.numeric(TIV_CH4_noncombustion_oil_europe), - TIV_CH4_noncombustion_anthracite_europe = as.numeric(TIV_CH4_noncombustion_anthracite_europe), - TIV_CH4_noncombustion_bituminouscoal_europe = as.numeric(TIV_CH4_noncombustion_bituminouscoal_europe), - TIV_CH4_noncombustion_cokingcoal_europe = as.numeric(TIV_CH4_noncombustion_cokingcoal_europe), - TIV_CH4_noncombustion_lignite_europe = as.numeric(TIV_CH4_noncombustion_lignite_europe), - TIV_CH4_noncombustion_subbituminouscoal_europe = as.numeric(TIV_CH4_noncombustion_subbituminouscoal_europe), - TIV_CH4_noncombustion_oilrefinery_europe = as.numeric(TIV_CH4_noncombustion_oilrefinery_europe), - TIV_CH4_agriculture_europe = as.numeric(TIV_CH4_agriculture_europe), - TIV_CH4_waste_europe = as.numeric(TIV_CH4_waste_europe), - TIV_N2O_europe = as.numeric(TIV_N2O_europe), - TIV_N2O_agriculture_europe = as.numeric(TIV_N2O_agriculture_europe), - TIV_SF6_europe = as.numeric(TIV_SF6_europe), - TIV_HFC_europe = as.numeric(TIV_HFC_europe), - TIV_PFC_europe = as.numeric(TIV_PFC_europe), - TIV_energy_europe = as.numeric(TIV_energy_europe), - TIV_biomass_europe = as.numeric(TIV_biomass_europe), - TIV_const_materials_europe = as.numeric(TIV_const_materials_europe), - TIV_ffuels_europe = as.numeric(TIV_ffuels_europe), - TIV_ores_europe = as.numeric(TIV_ores_europe), - TIV_cropland_europe = as.numeric(TIV_cropland_europe), - TIV_forest_land_europe = as.numeric(TIV_forest_land_europe), - TIV_pasture_land_europe = as.numeric(TIV_pasture_land_europe)) - - europe_TIVs = rbind(europe_TIVs, look_europe) - - - - # total national footprints - - # FD labels - - Exiobase_FD_labels = as.data.frame(t(read.csv(paste0(data_dir_exiobase, "/Exiobase_FD_labels_ixi.csv")))[-1,-3]) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - national_CO2_footprints = Exiobase_FD * t(Exiobase_TIV_co2_bp) - - national_CO2_noncombustion_cement_footprints = Exiobase_FD * t(Exiobase_TIV_co2_noncombustion_cement_bp) - - national_CO2_noncombustion_lime_footprints = Exiobase_FD * t(Exiobase_TIV_co2_noncombustion_lime_bp) - - national_CO2_agriculture_peatdecay_footprints = Exiobase_FD * t(Exiobase_TIV_co2_agriculture_peatdecay_bp) - - national_CO2_waste_biogenic_footprints = Exiobase_FD * t(Exiobase_TIV_co2_waste_biogenic_bp) - - national_CO2_waste_fossil_footprints = Exiobase_FD * t(Exiobase_TIV_co2_waste_fossil_bp) - - national_CH4_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_bp) - - national_CH4_noncombustion_gas_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_gas_bp) - - national_CH4_noncombustion_oil_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_oil_bp) - - national_CH4_noncombustion_anthracite_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_anthracite_bp) - - national_CH4_noncombustion_bituminouscoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp) - - national_CH4_noncombustion_cokingcoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp) - - national_CH4_noncombustion_lignite_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_lignite_bp) - - national_CH4_noncombustion_subbituminouscoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp) - - national_CH4_noncombustion_oilrefinery_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp) - - national_CH4_agriculture_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_agriculture_bp) - - national_CH4_waste_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_waste_bp) - - national_N2O_footprints = Exiobase_FD * t(Exiobase_TIV_n2o_bp) - - national_N2O_agriculture_footprints = Exiobase_FD * t(Exiobase_TIV_n2o_agriculture_bp) - - national_SF6_footprints = Exiobase_FD * t(Exiobase_TIV_sf6_bp) - - national_HFC_footprints = Exiobase_FD * t(Exiobase_TIV_hfc_bp) - - national_PFC_footprints = Exiobase_FD * t(Exiobase_TIV_pfc_bp) - - national_energy_footprints = Exiobase_FD * t(Exiobase_TIV_energy_use_bp) - - national_biomass_footprints = Exiobase_FD * t(Exiobase_TIV_biomass_bp) - - national_const_materials_footprints = Exiobase_FD * t(Exiobase_TIV_const_materials_bp) - - national_ffuels_footprints = Exiobase_FD * t(Exiobase_TIV_ffuels_bp) - - national_ores_footprints = Exiobase_FD * t(Exiobase_TIV_ores_bp) - - national_cropland_footprints = Exiobase_FD * t(Exiobase_TIV_cropland_bp) - - national_forest_land_footprints = Exiobase_FD * t(Exiobase_TIV_forest_land_bp) - - national_pasture_land_footprints = Exiobase_FD * t(Exiobase_TIV_pasture_land_bp) - - - # together - - national_footprints_w_labels = cbind(Exiobase_FD_labels, - rowSums(t(national_CO2_footprints)), - rowSums(t(national_CO2_noncombustion_cement_footprints)), - rowSums(t(national_CO2_noncombustion_lime_footprints)), - rowSums(t(national_CO2_agriculture_peatdecay_footprints)), - rowSums(t(national_CO2_waste_biogenic_footprints)), - rowSums(t(national_CO2_waste_fossil_footprints)), - rowSums(t(national_CH4_footprints)), - rowSums(t(national_CH4_noncombustion_gas_footprints)), - rowSums(t(national_CH4_noncombustion_oil_footprints)), - rowSums(t(national_CH4_noncombustion_anthracite_footprints)), - rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints)), - rowSums(t(national_CH4_noncombustion_cokingcoal_footprints)), - rowSums(t(national_CH4_noncombustion_lignite_footprints)), - rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints)), - rowSums(t(national_CH4_noncombustion_oilrefinery_footprints)), - rowSums(t(national_CH4_agriculture_footprints)), - rowSums(t(national_CH4_waste_footprints)), - rowSums(t(national_N2O_footprints)), - rowSums(t(national_N2O_agriculture_footprints)), - rowSums(t(national_SF6_footprints)), - rowSums(t(national_HFC_footprints)), - rowSums(t(national_PFC_footprints)), - rowSums(t(national_energy_footprints)), - rowSums(t(national_biomass_footprints)), - rowSums(t(national_const_materials_footprints)), - rowSums(t(national_ffuels_footprints)), - rowSums(t(national_ores_footprints)), - rowSums(t(national_cropland_footprints)), - rowSums(t(national_forest_land_footprints)), - rowSums(t(national_pasture_land_footprints))) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year_national_fp = as.character(rep(year_current,nrow(national_footprints_w_labels))) - - # direct FD emissions - - direct_FD_extensions = read.csv(paste0(data_dir_exiobase, "/IOT_", year_current, "_ixi/satellite/F_hh.csv", sep = ""),row.names=NULL,as.is=TRUE)[3:1115,3:345] - direct_FD_extensions[is.na(direct_FD_extensions)]=0 - direct_FD_extensions = mapply(direct_FD_extensions, FUN = as.numeric) - direct_FD_extensions = matrix(data=direct_FD_extensions,ncol=343,nrow=1113) - - direct_FD_co2 = direct_FD_extensions[24,] - direct_FD_co2_noncombustion_cement = direct_FD_extensions[93,] - direct_FD_co2_noncombustion_lime = direct_FD_extensions[94,] - direct_FD_co2_agriculture_peatdecay = direct_FD_extensions[428,] - direct_FD_co2_waste_biogenic = direct_FD_extensions[438,] - direct_FD_co2_waste_fossil = direct_FD_extensions[439,] - direct_FD_ch4 = direct_FD_extensions[25,]*28 - direct_FD_ch4_noncombustion_gas = direct_FD_extensions[68,]*28 - direct_FD_ch4_noncombustion_oil = direct_FD_extensions[69,]*28 - direct_FD_ch4_noncombustion_anthracite = direct_FD_extensions[70,]*28 - direct_FD_ch4_noncombustion_bituminouscoal = direct_FD_extensions[71,]*28 - direct_FD_ch4_noncombustion_cokingcoal = direct_FD_extensions[72,]*28 - direct_FD_ch4_noncombustion_lignite = direct_FD_extensions[73,]*28 - direct_FD_ch4_noncombustion_subbituminouscoal = direct_FD_extensions[74,]*28 - direct_FD_ch4_noncombustion_oilrefinery = direct_FD_extensions[75,]*28 - direct_FD_ch4_agriculture = direct_FD_extensions[427,]*28 - direct_FD_ch4_waste = direct_FD_extensions[436,]*28 - direct_FD_n2o = direct_FD_extensions[26,]*265 - direct_FD_n2o_agriculture = direct_FD_extensions[430,]*265 - direct_FD_sf6 = direct_FD_extensions[424,]*23500 - direct_FD_hfc = direct_FD_extensions[425,] - direct_FD_pfc = direct_FD_extensions[426,] - direct_FD_energy = direct_FD_extensions[470,] - direct_FD_biomass = colSums(direct_FD_extensions[c(471:499,501,522:688),]) - direct_FD_const_materials = colSums(direct_FD_extensions[514:521,]) - direct_FD_ffuels = direct_FD_extensions[500,] - direct_FD_ores = colSums(direct_FD_extensions[502:513,]) - direct_FD_cropland = colSums(direct_FD_extensions[447:459,]) - direct_FD_forest_land = colSums(direct_FD_extensions[c(460,466),]) - direct_FD_pasture_land = colSums(direct_FD_extensions[462:464,]) - - - direct_FD_fp = data.frame(direct_FD_co2, - direct_FD_co2_noncombustion_cement, - direct_FD_co2_noncombustion_lime, - direct_FD_co2_agriculture_peatdecay, - direct_FD_co2_waste_biogenic, - direct_FD_co2_waste_fossil, - direct_FD_ch4, - direct_FD_ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_oilrefinery, - direct_FD_ch4_agriculture, - direct_FD_ch4_waste, - direct_FD_n2o, - direct_FD_n2o_agriculture, - direct_FD_sf6, - direct_FD_hfc, - direct_FD_pfc, - direct_FD_energy, - direct_FD_biomass, - direct_FD_const_materials, - direct_FD_ffuels, - direct_FD_ores, - direct_FD_cropland, - direct_FD_forest_land, - direct_FD_pasture_land) - - look_national_fp = as.data.frame(cbind(year_national_fp, - national_footprints_w_labels, - direct_FD_fp)) %>% - rename(year = year_national_fp, - geo = V1, - fd_category = V2, - co2 = "rowSums(t(national_CO2_footprints))", - co2_noncombustion_cement = "rowSums(t(national_CO2_noncombustion_cement_footprints))", - co2_noncombustion_lime = "rowSums(t(national_CO2_noncombustion_lime_footprints))", - co2_agriculture_peatdecay = "rowSums(t(national_CO2_agriculture_peatdecay_footprints))", - co2_waste_biogenic = "rowSums(t(national_CO2_waste_biogenic_footprints))", - co2_waste_fossil = "rowSums(t(national_CO2_waste_fossil_footprints))", - ch4 = "rowSums(t(national_CH4_footprints))", - ch4_noncombustion_gas = "rowSums(t(national_CH4_noncombustion_gas_footprints))", - ch4_noncombustion_oil = "rowSums(t(national_CH4_noncombustion_oil_footprints))", - ch4_noncombustion_anthracite = "rowSums(t(national_CH4_noncombustion_anthracite_footprints))", - ch4_noncombustion_bituminouscoal = "rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints))", - ch4_noncombustion_cokingcoal = "rowSums(t(national_CH4_noncombustion_cokingcoal_footprints))", - ch4_noncombustion_lignite = "rowSums(t(national_CH4_noncombustion_lignite_footprints))", - ch4_noncombustion_subbituminouscoal = "rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints))", - ch4_noncombustion_oilrefinery = "rowSums(t(national_CH4_noncombustion_oilrefinery_footprints))", - ch4_agriculture = "rowSums(t(national_CH4_agriculture_footprints))", - ch4_waste = "rowSums(t(national_CH4_waste_footprints))", - n2o = "rowSums(t(national_N2O_footprints))", - n2o_agriculture = "rowSums(t(national_N2O_agriculture_footprints))", - sf6 = "rowSums(t(national_SF6_footprints))", - hfc = "rowSums(t(national_HFC_footprints))", - pfc = "rowSums(t(national_PFC_footprints))", - energy = "rowSums(t(national_energy_footprints))", - biomass = "rowSums(t(national_biomass_footprints))", - const_materials = "rowSums(t(national_const_materials_footprints))", - ffuels = "rowSums(t(national_ffuels_footprints))", - ores = "rowSums(t(national_ores_footprints))", - cropland = "rowSums(t(national_cropland_footprints))", - forest_land = "rowSums(t(national_forest_land_footprints))", - pasture_land = "rowSums(t(national_pasture_land_footprints))") %>% - select(year, - geo, - fd_category, - co2, - direct_FD_co2, - co2_noncombustion_cement, - direct_FD_co2_noncombustion_cement, - co2_noncombustion_lime, - direct_FD_co2_noncombustion_lime, - co2_agriculture_peatdecay, - direct_FD_co2_agriculture_peatdecay, - co2_waste_biogenic, - direct_FD_co2_waste_biogenic, - co2_waste_fossil, - direct_FD_co2_waste_fossil, - ch4, - direct_FD_ch4, - ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_gas, - ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_oil, - ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_anthracite, - ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_bituminouscoal, - ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_cokingcoal, - ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_lignite, - ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_subbituminouscoal, - ch4_noncombustion_oilrefinery, - direct_FD_ch4_noncombustion_oilrefinery, - ch4_agriculture, - direct_FD_ch4_agriculture, - ch4_waste, - direct_FD_ch4_waste, - n2o, - direct_FD_n2o, - n2o_agriculture, - direct_FD_n2o_agriculture, - sf6, - direct_FD_sf6, - hfc, - direct_FD_hfc, - pfc, - direct_FD_pfc, - energy, - direct_FD_energy, - biomass, - direct_FD_biomass, - const_materials, - direct_FD_const_materials, - ffuels, - direct_FD_ffuels, - ores, - direct_FD_ores, - cropland, - direct_FD_cropland, - forest_land, - direct_FD_forest_land, - pasture_land, - direct_FD_pasture_land) - - - national_fp = rbind(national_fp, look_national_fp) - - - - # national territorial - - satellite = read.csv(paste0(data_dir_exiobase, "/IOT_", year_current, "_ixi/satellite/satellite_",year_current,"_ixi.csv"))[,-1] - - - CO2_combustion_air = satellite[24,] - - CO2_noncombustion_cement_air = satellite[93,] - - CO2_noncombustion_lime_air = satellite[94,] - - CO2_agriculture_peatdecay_air = satellite[428,] - - CO2_waste_biogenic_air = satellite[438,] - - CO2_waste_fossil_air = satellite[439,] - - CH4_combustion_air = satellite[25,] - CH4_combustion_air = CH4_combustion_air*28 - - CH4_noncombustion_gas_air = satellite[68,] - CH4_noncombustion_gas_air = CH4_noncombustion_gas_air*28 - - CH4_noncombustion_oil_air = satellite[69,] - CH4_noncombustion_oil_air = CH4_noncombustion_oil_air*28 - - CH4_noncombustion_anthracite_air = satellite[70,] - CH4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air*28 - - CH4_noncombustion_bituminouscoal_air = satellite[71,] - CH4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air*28 - - CH4_noncombustion_cokingcoal_air = satellite[72,] - CH4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air*28 - - CH4_noncombustion_lignite_air = satellite[73,] - CH4_noncombustion_lignite_air = CH4_noncombustion_lignite_air*28 - - CH4_noncombustion_subbituminouscoal_air = satellite[74,] - CH4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air*28 - - CH4_noncombustion_oilrefinery_air = satellite[75,] - CH4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air*28 - - CH4_agriculture_air = satellite[427,] - CH4_agriculture_air = CH4_agriculture_air*28 - - CH4_waste_air = satellite[436,] - CH4_waste_air = CH4_waste_air*28 - - N2O_combustion_air = satellite[26,] - N2O_combustion_air = N2O_combustion_air*265 - - N2O_agriculture_air = satellite[430,] - N2O_agriculture_air = N2O_agriculture_air*265 - - SF6_air = satellite[424,] - SF6_air = SF6_air*23500 - - HFC_air = satellite[425,] - - PFC_air = satellite[426,] - - energy_carrier_use = satellite[470,] - - biomass = as.data.frame(colSums(satellite[c(471:499,501,522:688),])) - - ores = as.data.frame(colSums(satellite[502:513,])) - - const_materials = as.data.frame(colSums(satellite[514:521,])) - - ffuels = satellite[500,] - - cropland = as.data.frame(colSums(satellite[447:459,])) - - pasture_land = as.data.frame(colSums(satellite[462:464,])) - - forest_land = as.data.frame(colSums(satellite[c(460,466),])) - - - territorial = data.frame(t(CO2_combustion_air), - t(CO2_noncombustion_cement_air), - t(CO2_noncombustion_lime_air), - t(CO2_agriculture_peatdecay_air), - t(CO2_waste_biogenic_air), - t(CO2_waste_fossil_air), - t(CH4_combustion_air), - t(CH4_noncombustion_gas_air), - t(CH4_noncombustion_oil_air), - t(CH4_noncombustion_anthracite_air), - t(CH4_noncombustion_bituminouscoal_air), - t(CH4_noncombustion_cokingcoal_air), - t(CH4_noncombustion_lignite_air), - t(CH4_noncombustion_subbituminouscoal_air), - t(CH4_noncombustion_oilrefinery_air), - t(CH4_agriculture_air), - t(CH4_waste_air), - t(N2O_combustion_air), - t(N2O_agriculture_air), - t(SF6_air), - t(HFC_air), - t(PFC_air), - t(energy_carrier_use), - biomass, - ores, - const_materials, - t(ffuels), - cropland, - pasture_land, - forest_land) %>% - rename(CO2 = 1, - CO2_noncombustion_cement = 2, - CO2_noncombustion_lime = 3, - CO2_agriculture_peatdecay = 4, - CO2_waste_biogenic = 5, - CO2_waste_fossil = 6, - CH4 = 7, - CH4_noncombustion_gas = 8, - CH4_noncombustion_oil = 9, - CH4_noncombustion_anthracite = 10, - CH4_noncombustion_bituminouscoal = 11, - CH4_noncombustion_cokingcoal = 12, - CH4_noncombustion_lignite = 13, - CH4_noncombustion_subbituminouscoal = 14, - CH4_noncombustion_oilrefinery = 15, - CH4_agriculture = 16, - CH4_waste = 17, - N2O = 18, - N2O_agriculture = 19, - SF6 = 20, - HFC = 21, PFC = 22, energy = 23, - biomass = 24, ores = 25, - const_materials = 26, ffuels = 27, - cropland = 28, pasture_land = 29, - forest_land = 30) - - year_territorial = as.character(rep(year_current,nrow(territorial))) - - look_territorial = as.data.frame(cbind(year_territorial, - Exiobase_T_labels, - territorial)) %>% - rename(year = year_territorial, - geo = V1, - sector = V2) %>% - select(-coicop,-five_sectors) - - national_territorial = rbind(national_territorial, look_territorial) - -} - -write.csv(national_territorial, paste0(data_dir_income_stratified_footprints, "/national_territorial_ixi.csv")) -write_rds(national_territorial, paste0(data_dir_income_stratified_footprints, "/national_territorial_ixi.rds")) - - -write.csv(national_fp, paste0(data_dir_income_stratified_footprints, "/national_fp_ixi.csv")) -write_rds(national_fp, paste0(data_dir_income_stratified_footprints, "/national_fp_ixi.rds")) - -# calculate quintile shares within each sector -shares = join_expenditures %>% - group_by(coicop,geo,year) %>% - mutate(share = pps_coicop/sum(pps_coicop)) - -# pre-processing - -fd_exiobase = disaggregated_final_demand %>% - left_join(shares, by = c("year","geo","coicop","quintile")) %>% - mutate(disaggregated_fd = value*share) %>% - select(year,geo,quintile,country_of_production,sector,coicop,disaggregated_fd) %>% - spread(quintile,disaggregated_fd) - -# direct from FD - to go back to results without direct FD fp, do not run this next chunk and do not bind_rows with 'results' - -env_ac_pefasu_no_TR = read_csv(paste0(data_dir_income_stratified_footprints, "/data/env_ac_pefasu_1_Data.csv")) %>% - filter(TIME == 2015) %>% - mutate(geo = dplyr::recode(GEO,"Austria" = "AT", - "Belgium" = "BE", - "Cyprus" = "CY", - "Czechia" = "CZ", - "Denmark" = "DK", - "Estonia" = "EE", - "Finland" = "FI", - "France" = "FR", - "Germany (until 1990 former territory of the FRG)" = "DE", - "Greece" = "EL", - "Hungary" = "HU", - "Ireland" = "IE", - "Italy" = "IT", - "Latvia" = "LV", - "Lithuania" = "LT", - "Luxembourg" = "LU", - "Malta" = "MT", - "Netherlands" = "NL", - "Norway" = "NO", - "Poland" = "PL", - "Portugal" = "PT", - "Romania" = "RO", - "Slovakia" = "SK", - "Slovenia" = "SI", - "Spain" = "ES", - "Sweden" = "SE", - "United Kingdom" = "UK", - "Bulgaria" = "BG", - "Croatia" = "HR")) %>% - select(NACE_R2,geo,Value) %>% - mutate(Value = parse_number(Value), - Value = as.numeric(Value)) %>% - spread(NACE_R2,Value) %>% - clean_names() %>% - mutate(HH_HEAT = heating_cooling_activities_by_households/total_activities_by_households, - HH_TRA = transport_activities_by_households/total_activities_by_households, - HH_OTH = other_activities_by_households/total_activities_by_households) %>% - select(geo,HH_HEAT,HH_TRA,HH_OTH) - - -env_ac_pefasu_TR = env_ac_pefasu_no_TR %>% - filter(geo == "BG") %>% - mutate(geo = dplyr::recode(geo, - "BG" = "TR")) - -env_ac_pefasu = rbind(env_ac_pefasu_no_TR,env_ac_pefasu_TR) %>% - gather(sector,share_of_total_energy,-geo) - -env_ac_ainah_r2 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/env_ac_ainah_r2_1_Data.csv")) %>% - filter(TIME == 2015) %>% - mutate(geo = dplyr::recode(GEO,"Austria" = "AT", - "Belgium" = "BE", - "Cyprus" = "CY", - "Czechia" = "CZ", - "Denmark" = "DK", - "Estonia" = "EE", - "Finland" = "FI", - "France" = "FR", - "Germany (until 1990 former territory of the FRG)" = "DE", - "Greece" = "EL", - "Hungary" = "HU", - "Ireland" = "IE", - "Italy" = "IT", - "Latvia" = "LV", - "Lithuania" = "LT", - "Luxembourg" = "LU", - "Malta" = "MT", - "Netherlands" = "NL", - "Norway" = "NO", - "Poland" = "PL", - "Portugal" = "PT", - "Romania" = "RO", - "Slovakia" = "SK", - "Slovenia" = "SI", - "Spain" = "ES", - "Sweden" = "SE", - "Turkey" = "TR", - "United Kingdom" = "UK", - "Bulgaria" = "BG", - "Croatia" = "HR")) %>% - select(NACE_R2,AIRPOL,geo,Value) %>% - mutate(Value = parse_number(Value), - Value = as.numeric(Value)) %>% - spread(NACE_R2,Value) %>% - clean_names() %>% - mutate(HH_HEAT = heating_cooling_activities_by_households/total_activities_by_households, - HH_TRA = transport_activities_by_households/total_activities_by_households, - HH_OTH = other_activities_by_households/total_activities_by_households) %>% - select(geo,airpol,HH_HEAT,HH_TRA,HH_OTH) - - -env_ac_ainah_r2_co2 = env_ac_ainah_r2 %>% - filter(airpol == "Carbon dioxide") %>% - select(-airpol) %>% - gather(sector,share_of_total_co2,-geo) - -env_ac_ainah_r2_ch4 = env_ac_ainah_r2 %>% - filter(airpol == "Methane") %>% - select(-airpol) %>% - gather(sector,share_of_total_ch4,-geo) - -env_ac_ainah_r2_n2o = env_ac_ainah_r2 %>% - filter(airpol == "Nitrous oxide") %>% - select(-airpol) %>% - gather(sector,share_of_total_n2o,-geo) - -direct_FD_fp_long = national_fp %>% - filter(fd_category == "Final consumption expenditure by households", - geo %in% c("AT", - "BE", "BG", "CY", "CZ", - "DE" , "DK" , "EE" , - "ES" , "FI" , "FR" , - "UK", "EL", "HR" , - "HU" , "IE" , "IT" , - "LT" , "LU" , "LV" , - "MT" , "NL" , "PL" , - "PT" , "TR" , "SK" , - "SI" , "SE" , "RO" , - "NO")) %>% - select(year,geo,fd_category,direct_FD_co2, - direct_FD_co2_noncombustion_cement, - direct_FD_co2_noncombustion_lime, - direct_FD_co2_agriculture_peatdecay, - direct_FD_co2_waste_biogenic, - direct_FD_co2_waste_fossil, - direct_FD_ch4, - direct_FD_ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_oilrefinery, - direct_FD_ch4_agriculture, - direct_FD_ch4_waste, - direct_FD_n2o, - direct_FD_n2o_agriculture, - direct_FD_sf6, - direct_FD_hfc, - direct_FD_pfc, - direct_FD_energy, - direct_FD_biomass, - direct_FD_const_materials, - direct_FD_ffuels, - direct_FD_ores, - direct_FD_cropland, - direct_FD_forest_land, - direct_FD_pasture_land) %>% - slice(rep(1:n(), each = 3)) - -sector = rep(c("HH_HEAT","HH_TRA","HH_OTH"), nrow(direct_FD_fp_long)/3) - -direct_FD_fp_long_disagg = cbind(sector,direct_FD_fp_long) %>% - mutate(coicop = ifelse(sector == "HH_TRA","CP072", - ifelse(sector == "HH_HEAT","CP045","CP05")), - five_sectors = ifelse(sector == "HH_TRA", "transport", - ifelse(sector == "HH_HEAT", "shelter", "manufactured goods"))) %>% - left_join(env_ac_ainah_r2_co2, by = c("geo","sector")) %>% - left_join(env_ac_ainah_r2_ch4, by = c("geo","sector")) %>% - left_join(env_ac_ainah_r2_n2o, by = c("geo","sector")) %>% - left_join(env_ac_pefasu, by = c("geo","sector")) %>% - mutate(direct_FD_co2 = (direct_FD_co2 + - direct_FD_co2_noncombustion_cement + - direct_FD_co2_noncombustion_lime + - direct_FD_co2_agriculture_peatdecay + - direct_FD_co2_waste_biogenic + - direct_FD_co2_waste_fossil)*share_of_total_co2, - direct_FD_ch4 = (direct_FD_ch4 + - direct_FD_ch4_noncombustion_gas + - direct_FD_ch4_noncombustion_oil + - direct_FD_ch4_noncombustion_anthracite + - direct_FD_ch4_noncombustion_bituminouscoal + - direct_FD_ch4_noncombustion_cokingcoal + - direct_FD_ch4_noncombustion_lignite + - direct_FD_ch4_noncombustion_subbituminouscoal + - direct_FD_ch4_noncombustion_oilrefinery + - direct_FD_ch4_agriculture + - direct_FD_ch4_waste)*share_of_total_ch4, - direct_FD_n2o = (direct_FD_n2o + - direct_FD_n2o_agriculture)*share_of_total_n2o, - direct_FD_energy = direct_FD_energy*share_of_total_energy) %>% - left_join(shares, by = c("year","geo","coicop")) %>% - mutate(disaggregated_direct_FD_co2 = direct_FD_co2*share, - disaggregated_direct_FD_ch4 = direct_FD_ch4*share, - disaggregated_direct_FD_n2o = direct_FD_n2o*share, - disaggregated_direct_FD_energy = direct_FD_energy*share) %>% - select(year,geo,sector, quintile, - coicop, five_sectors, - disaggregated_direct_FD_co2, - disaggregated_direct_FD_ch4, - disaggregated_direct_FD_n2o, - disaggregated_direct_FD_energy) - -direct_FD_co2 = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_co2) %>% - spread(quintile,disaggregated_direct_FD_co2) %>% - rename(q1_co2 = QUINTILE1, - q2_co2 = QUINTILE2, - q3_co2 = QUINTILE3, - q4_co2 = QUINTILE4, - q5_co2 = QUINTILE5) %>% - mutate(q1_co2_domestic = q1_co2, - q2_co2_domestic = q2_co2, - q3_co2_domestic = q3_co2, - q4_co2_domestic = q4_co2, - q5_co2_domestic = q5_co2, - co2_total = q1_co2+q2_co2+q3_co2+q4_co2+q5_co2, - co2_total_domestic = q1_co2_domestic+ - q2_co2_domestic+q3_co2_domestic+ - q4_co2_domestic+q5_co2_domestic) - -direct_FD_ch4 = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_ch4) %>% - spread(quintile,disaggregated_direct_FD_ch4) %>% - rename(q1_ch4 = QUINTILE1, - q2_ch4 = QUINTILE2, - q3_ch4 = QUINTILE3, - q4_ch4 = QUINTILE4, - q5_ch4 = QUINTILE5) %>% - mutate(q1_ch4_domestic = q1_ch4, - q2_ch4_domestic = q2_ch4, - q3_ch4_domestic = q3_ch4, - q4_ch4_domestic = q4_ch4, - q5_ch4_domestic = q5_ch4, - ch4_total = q1_ch4+q2_ch4+q3_ch4+q4_ch4+q5_ch4, - ch4_total_domestic = q1_ch4_domestic+ - q2_ch4_domestic+q3_ch4_domestic+ - q4_ch4_domestic+q5_ch4_domestic) - - -direct_FD_n2o = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_n2o) %>% - spread(quintile,disaggregated_direct_FD_n2o) %>% - rename(q1_n2o = QUINTILE1, - q2_n2o = QUINTILE2, - q3_n2o = QUINTILE3, - q4_n2o = QUINTILE4, - q5_n2o = QUINTILE5) %>% - mutate(q1_n2o_domestic = q1_n2o, - q2_n2o_domestic = q2_n2o, - q3_n2o_domestic = q3_n2o, - q4_n2o_domestic = q4_n2o, - q5_n2o_domestic = q5_n2o, - n2o_total = q1_n2o+q2_n2o+q3_n2o+q4_n2o+q5_n2o, - n2o_total_domestic = q1_n2o_domestic+ - q2_n2o_domestic+q3_n2o_domestic+ - q4_n2o_domestic+q5_n2o_domestic) - -direct_FD_energy = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_energy) %>% - spread(quintile,disaggregated_direct_FD_energy) %>% - rename(q1_energy = QUINTILE1, - q2_energy = QUINTILE2, - q3_energy = QUINTILE3, - q4_energy = QUINTILE4, - q5_energy = QUINTILE5) %>% - mutate(q1_energy_domestic = q1_energy, - q2_energy_domestic = q2_energy, - q3_energy_domestic = q3_energy, - q4_energy_domestic = q4_energy, - q5_energy_domestic = q5_energy, - energy_total = q1_energy+q2_energy+q3_energy+q4_energy+q5_energy, - energy_total_domestic = q1_energy_domestic+ - q2_energy_domestic+q3_energy_domestic+ - q4_energy_domestic+q5_energy_domestic) - - -direct_FD_fp_wide = direct_FD_co2 %>% - left_join(direct_FD_ch4, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - left_join(direct_FD_n2o, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - left_join(direct_FD_energy, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - mutate(country_of_production = geo) %>% - mutate(q1_co2eq = q1_co2 + q1_ch4 + q1_n2o, - q2_co2eq = q2_co2 + q2_ch4 + q2_n2o, - q3_co2eq = q3_co2 + q3_ch4 + q3_n2o, - q4_co2eq = q4_co2 + q4_ch4 + q4_n2o, - q5_co2eq = q5_co2 + q5_ch4 + q5_n2o, - co2eq_total = q1_co2eq + - q2_co2eq + q3_co2eq + - q4_co2eq + q5_co2eq, - q1_co2eq_domestic = q1_co2_domestic + q1_ch4_domestic + q1_n2o_domestic, - q2_co2eq_domestic = q2_co2_domestic + q2_ch4_domestic + q2_n2o_domestic, - q3_co2eq_domestic = q3_co2_domestic + q3_ch4_domestic + q3_n2o_domestic, - q4_co2eq_domestic = q4_co2_domestic + q4_ch4_domestic + q4_n2o_domestic, - q5_co2eq_domestic = q5_co2_domestic + q5_ch4_domestic + q5_n2o_domestic, - co2eq_total_domestic = q1_co2eq_domestic + - q2_co2eq_domestic + q3_co2eq_domestic + - q4_co2eq_domestic + q5_co2eq_domestic) %>% - select(-q1_ch4, - -q2_ch4, - -q3_ch4, - -q4_ch4, - -q5_ch4, - -ch4_total, - -q1_ch4_domestic, - -q2_ch4_domestic, - -q3_ch4_domestic, - -q4_ch4_domestic, - -q5_ch4_domestic, - -ch4_total_domestic, - -q1_n2o, - -q2_n2o, - -q3_n2o, - -q4_n2o, - -q5_n2o, - -n2o_total, - -q1_n2o_domestic, - -q2_n2o_domestic, - -q3_n2o_domestic, - -q4_n2o_domestic, - -q5_n2o_domestic, - -n2o_total_domestic) - - - -results = fd_exiobase %>% - left_join(TIVs, by = c("year", "country_of_production", "coicop", "sector")) %>% - left_join(europe_TIVs, by = c("year", "country_of_production", "coicop", "sector", "five_sectors")) %>% - left_join(domestic_TIVs, by = c("year", "geo", "country_of_production", "coicop", "sector", "five_sectors")) %>% - transmute(year,geo,country_of_production,sector,coicop,five_sectors, - QUINTILE1, - QUINTILE2, - QUINTILE3, - QUINTILE4, - QUINTILE5, - fd_total = QUINTILE1+QUINTILE2+QUINTILE3+QUINTILE4+QUINTILE5, - TIV_CO2 = TIV_CO2 + - TIV_CO2_noncombustion_cement + - TIV_CO2_noncombustion_lime + - TIV_CO2_agriculture_peatdecay + - TIV_CO2_waste_biogenic + - TIV_CO2_waste_fossil, - q1_co2 = QUINTILE1*TIV_CO2, - q2_co2 = QUINTILE2*TIV_CO2, - q3_co2 = QUINTILE3*TIV_CO2, - q4_co2 = QUINTILE4*TIV_CO2, - q5_co2 = QUINTILE5*TIV_CO2, - co2_total = q1_co2+q2_co2+q3_co2+q4_co2+q5_co2, - TIV_CO2_domestic = TIV_CO2_domestic + - TIV_CO2_noncombustion_cement_domestic + - TIV_CO2_noncombustion_lime_domestic + - TIV_CO2_agriculture_peatdecay_domestic + - TIV_CO2_waste_biogenic_domestic + - TIV_CO2_waste_fossil_domestic, - q1_co2_domestic = QUINTILE1*TIV_CO2_domestic, - q2_co2_domestic = QUINTILE2*TIV_CO2_domestic, - q3_co2_domestic = QUINTILE3*TIV_CO2_domestic, - q4_co2_domestic = QUINTILE4*TIV_CO2_domestic, - q5_co2_domestic = QUINTILE5*TIV_CO2_domestic, - co2_total_domestic = q1_co2_domestic+q2_co2_domestic+q3_co2_domestic+q4_co2_domestic+q5_co2_domestic, - TIV_CO2_europe = TIV_CO2_europe + - TIV_CO2_noncombustion_cement_europe + - TIV_CO2_noncombustion_lime_europe + - TIV_CO2_agriculture_peatdecay_europe + - TIV_CO2_waste_biogenic_europe + - TIV_CO2_waste_fossil_europe, - q1_co2_europe = QUINTILE1*(TIV_CO2_europe - TIV_CO2_domestic), - q2_co2_europe = QUINTILE2*(TIV_CO2_europe - TIV_CO2_domestic), - q3_co2_europe = QUINTILE3*(TIV_CO2_europe - TIV_CO2_domestic), - q4_co2_europe = QUINTILE4*(TIV_CO2_europe - TIV_CO2_domestic), - q5_co2_europe = QUINTILE5*(TIV_CO2_europe - TIV_CO2_domestic), - co2_total_europe = q1_co2_europe+q2_co2_europe+q3_co2_europe+q4_co2_europe+q5_co2_europe, - TIV_CO2eq = TIV_CO2 + - TIV_CH4 + - TIV_CH4_noncombustion_gas + - TIV_CH4_noncombustion_oil + - TIV_CH4_noncombustion_anthracite + - TIV_CH4_noncombustion_bituminouscoal + - TIV_CH4_noncombustion_cokingcoal + - TIV_CH4_noncombustion_lignite + - TIV_CH4_noncombustion_subbituminouscoal + - TIV_CH4_noncombustion_oilrefinery + - TIV_CH4_agriculture + - TIV_CH4_waste + - TIV_N2O + - TIV_N2O_agriculture + - TIV_SF6 + TIV_HFC + TIV_PFC, - q1_co2eq = QUINTILE1*TIV_CO2eq, - q2_co2eq = QUINTILE2*TIV_CO2eq, - q3_co2eq = QUINTILE3*TIV_CO2eq, - q4_co2eq = QUINTILE4*TIV_CO2eq, - q5_co2eq = QUINTILE5*TIV_CO2eq, - co2eq_total = q1_co2eq + q2_co2eq + q3_co2eq + q4_co2eq + q5_co2eq, - TIV_CO2eq_domestic = TIV_CO2_domestic + - TIV_CH4_domestic + - TIV_CH4_noncombustion_gas_domestic + - TIV_CH4_noncombustion_oil_domestic + - TIV_CH4_noncombustion_anthracite_domestic + - TIV_CH4_noncombustion_bituminouscoal_domestic + - TIV_CH4_noncombustion_cokingcoal_domestic + - TIV_CH4_noncombustion_lignite_domestic + - TIV_CH4_noncombustion_subbituminouscoal_domestic + - TIV_CH4_noncombustion_oilrefinery_domestic + - TIV_CH4_agriculture_domestic + - TIV_CH4_waste_domestic + - TIV_N2O_domestic + - TIV_N2O_agriculture_domestic + - TIV_SF6_domestic + TIV_HFC_domestic + TIV_PFC_domestic, - q1_co2eq_domestic = QUINTILE1*TIV_CO2eq_domestic, - q2_co2eq_domestic = QUINTILE2*TIV_CO2eq_domestic, - q3_co2eq_domestic = QUINTILE3*TIV_CO2eq_domestic, - q4_co2eq_domestic = QUINTILE4*TIV_CO2eq_domestic, - q5_co2eq_domestic = QUINTILE5*TIV_CO2eq_domestic, - co2eq_total_domestic = q1_co2eq_domestic + q2_co2eq_domestic + q3_co2eq_domestic + q4_co2eq_domestic + q5_co2eq_domestic, - TIV_CO2eq_europe = TIV_CO2_europe + - TIV_CH4_europe + - TIV_CH4_noncombustion_gas_europe + - TIV_CH4_noncombustion_oil_europe + - TIV_CH4_noncombustion_anthracite_europe + - TIV_CH4_noncombustion_bituminouscoal_europe + - TIV_CH4_noncombustion_cokingcoal_europe + - TIV_CH4_noncombustion_lignite_europe + - TIV_CH4_noncombustion_subbituminouscoal_europe + - TIV_CH4_noncombustion_oilrefinery_europe + - TIV_CH4_agriculture_europe + - TIV_CH4_waste_europe + - TIV_N2O_europe + - TIV_N2O_agriculture_europe + - TIV_SF6_europe + TIV_HFC_europe + TIV_PFC_europe, - q1_co2eq_europe = QUINTILE1*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q2_co2eq_europe = QUINTILE2*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q3_co2eq_europe = QUINTILE3*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q4_co2eq_europe = QUINTILE4*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q5_co2eq_europe = QUINTILE5*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - co2eq_total_europe = q1_co2eq_europe + q2_co2eq_europe + q3_co2eq_europe + q4_co2eq_europe + q5_co2eq_europe, - TIV_energy, - q1_energy = QUINTILE1*TIV_energy, - q2_energy = QUINTILE2*TIV_energy, - q3_energy = QUINTILE3*TIV_energy, - q4_energy = QUINTILE4*TIV_energy, - q5_energy = QUINTILE5*TIV_energy, - energy_total = q1_energy+q2_energy+q3_energy+q4_energy+q5_energy, - TIV_energy_domestic, - q1_energy_domestic = QUINTILE1*TIV_energy_domestic, - q2_energy_domestic = QUINTILE2*TIV_energy_domestic, - q3_energy_domestic = QUINTILE3*TIV_energy_domestic, - q4_energy_domestic = QUINTILE4*TIV_energy_domestic, - q5_energy_domestic = QUINTILE5*TIV_energy_domestic, - energy_total_domestic = q1_energy_domestic+q2_energy_domestic+q3_energy_domestic+q4_energy_domestic+q5_energy_domestic, - TIV_energy_europe, - q1_energy_europe = QUINTILE1*(TIV_energy_europe - TIV_energy_domestic), - q2_energy_europe = QUINTILE2*(TIV_energy_europe - TIV_energy_domestic), - q3_energy_europe = QUINTILE3*(TIV_energy_europe - TIV_energy_domestic), - q4_energy_europe = QUINTILE4*(TIV_energy_europe - TIV_energy_domestic), - q5_energy_europe = QUINTILE5*(TIV_energy_europe - TIV_energy_domestic), - energy_total_europe = q1_energy_europe+q2_energy_europe+q3_energy_europe+q4_energy_europe+q5_energy_europe, - TIV_materials = TIV_biomass+TIV_const_materials+TIV_ffuels+TIV_ores, - q1_materials = QUINTILE1*TIV_materials, - q2_materials = QUINTILE2*TIV_materials, - q3_materials = QUINTILE3*TIV_materials, - q4_materials = QUINTILE4*TIV_materials, - q5_materials = QUINTILE5*TIV_materials, - materials_total = q1_materials+q2_materials+q3_materials+q4_materials+q5_materials, - TIV_materials_domestic = TIV_biomass_domestic+TIV_const_materials_domestic+TIV_ffuels_domestic+TIV_ores_domestic, - q1_materials_domestic = QUINTILE1*TIV_materials_domestic, - q2_materials_domestic = QUINTILE2*TIV_materials_domestic, - q3_materials_domestic = QUINTILE3*TIV_materials_domestic, - q4_materials_domestic = QUINTILE4*TIV_materials_domestic, - q5_materials_domestic = QUINTILE5*TIV_materials_domestic, - materials_total_domestic = q1_materials_domestic+q2_materials_domestic+q3_materials_domestic+q4_materials_domestic+q5_materials_domestic, - TIV_materials_europe = TIV_biomass_europe+TIV_const_materials_europe+TIV_ffuels_europe+TIV_ores_europe, - q1_materials_europe = QUINTILE1*(TIV_materials_europe - TIV_materials_domestic), - q2_materials_europe = QUINTILE2*(TIV_materials_europe - TIV_materials_domestic), - q3_materials_europe = QUINTILE3*(TIV_materials_europe - TIV_materials_domestic), - q4_materials_europe = QUINTILE4*(TIV_materials_europe - TIV_materials_domestic), - q5_materials_europe = QUINTILE5*(TIV_materials_europe - TIV_materials_domestic), - materials_total_europe = q1_materials_europe+q2_materials_europe+q3_materials_europe+q4_materials_europe+q5_materials_europe, - TIV_land_use = TIV_cropland+TIV_forest_land+TIV_pasture_land, - q1_land_use = QUINTILE1*TIV_land_use, - q2_land_use = QUINTILE2*TIV_land_use, - q3_land_use = QUINTILE3*TIV_land_use, - q4_land_use = QUINTILE4*TIV_land_use, - q5_land_use = QUINTILE5*TIV_land_use, - land_use_total =q1_land_use+q2_land_use+q3_land_use+q4_land_use+q5_land_use, - TIV_land_use_domestic = TIV_cropland_domestic+TIV_forest_land_domestic+TIV_pasture_land_domestic, - q1_land_use_domestic = QUINTILE1*TIV_land_use_domestic, - q2_land_use_domestic = QUINTILE2*TIV_land_use_domestic, - q3_land_use_domestic = QUINTILE3*TIV_land_use_domestic, - q4_land_use_domestic = QUINTILE4*TIV_land_use_domestic, - q5_land_use_domestic = QUINTILE5*TIV_land_use_domestic, - land_use_total_domestic =q1_land_use_domestic+q2_land_use_domestic+q3_land_use_domestic+q4_land_use_domestic+q5_land_use_domestic, - TIV_land_use_europe = TIV_cropland_europe+TIV_forest_land_europe+TIV_pasture_land_europe, - q1_land_use_europe = QUINTILE1*(TIV_land_use_europe - TIV_land_use_domestic), - q2_land_use_europe = QUINTILE2*(TIV_land_use_europe - TIV_land_use_domestic), - q3_land_use_europe = QUINTILE3*(TIV_land_use_europe - TIV_land_use_domestic), - q4_land_use_europe = QUINTILE4*(TIV_land_use_europe - TIV_land_use_domestic), - q5_land_use_europe = QUINTILE5*(TIV_land_use_europe - TIV_land_use_domestic), - land_use_total_europe =q1_land_use_europe+q2_land_use_europe+q3_land_use_europe+q4_land_use_europe+q5_land_use_europe) - -results_with_direct_FD_fp = bind_rows(results,direct_FD_fp_wide) - -#write.csv(results, paste0(data_dir_income_stratified_footprints, "/results_no_rent_ixi.csv")) - - -### create compressed results_ixi rds file - -#if (!require("pacman")) install.packages("pacman") -#pacman::p_load(tidyverse, -# janitor, -# here) - -#dat_all = read_csv(here("data/results_ixi.csv")) %>% -# clean_names() - -dat_all = results_with_direct_FD_fp %>% - clean_names() - -# convert sector labels to IDs -sectors = dat_all %>% - distinct(sector) %>% - mutate(sector_id = row_number()) - -#write_csv(sectors, here("data/sector_labels.csv")) -write_csv(sectors, paste0(data_dir_income_stratified_footprints, "/sectors_method1_ixi_pps_hh.csv")) - -# convert aggregated sector labels to IDs -sectors_agg = dat_all %>% - distinct(five_sectors) %>% - mutate(sector_agg_id = row_number()) - -#write_csv(sectors_agg, here("data/sector_agg_labels.csv")) -write_csv(sectors_agg, paste0(data_dir_income_stratified_footprints, "/sectors_agg_method1_ixi_pps_hh.csv")) - -# convert COICOP labels to IDs -coicop = dat_all %>% - distinct(coicop) %>% - mutate(coicop_id = row_number()) - -#write_csv(sectors_agg, here("data/sector_agg_labels.csv")) -write_csv(coicop, paste0(data_dir_income_stratified_footprints, "/coicop_method1_ixi_pps_hh.csv")) - -# replace sector text labels with numerical IDs (save space) -dat_compressed = dat_all %>% - left_join(sectors, by="sector") %>% - left_join(sectors_agg, by="five_sectors") %>% - left_join(coicop, by = "coicop") %>% - select(-c(sector, five_sectors,coicop)) - -# extract sector aggregation -sector_mapping = dat_compressed %>% - group_by(sector_id) %>% - summarise(sector_agg_id = first(sector_agg_id), - coicop_id = first(coicop_id)) - -# collapse country of origin -dat_results = dat_compressed %>% - select(-sector_agg_id,-coicop_id) %>% - group_by(year, geo, sector_id) %>% - summarise_if(is.numeric, sum, na.rm = TRUE) - -## extract final demand and pivot long -cols_final_demand = c("quintile1", "quintile2", "quintile3", "quintile4", "quintile5") -tmp_fd = dat_results %>% - select(year, geo, sector_id, cols_final_demand) %>% - pivot_longer(cols = cols_final_demand, - names_to = "quintile", - values_to = "fd_me") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 and pivot long -cols_co2 = c("q1_co2", "q2_co2", "q3_co2", "q4_co2", "q5_co2") -tmp_co2 = dat_results %>% - select(year, geo, sector_id, cols_co2) %>% - pivot_longer(cols = cols_co2, - names_to = "quintile", - values_to = "co2_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 domestic and pivot long -cols_co2_domestic = c("q1_co2_domestic", "q2_co2_domestic", "q3_co2_domestic", "q4_co2_domestic", "q5_co2_domestic") -tmp_co2_domestic = dat_results %>% - select(year, geo, sector_id, cols_co2_domestic) %>% - pivot_longer(cols = cols_co2_domestic, - names_to = "quintile", - values_to = "co2_domestic_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 europe and pivot long -cols_co2_europe = c("q1_co2_europe", "q2_co2_europe", "q3_co2_europe", "q4_co2_europe", "q5_co2_europe") -tmp_co2_europe = dat_results %>% - select(year, geo, sector_id, cols_co2_europe) %>% - pivot_longer(cols = cols_co2_europe, - names_to = "quintile", - values_to = "co2_europe_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - - -## extract co2eq and pivot long -cols_co2eq = c("q1_co2eq", "q2_co2eq", "q3_co2eq", "q4_co2eq", "q5_co2eq") -tmp_co2eq = dat_results %>% - select(year, geo, sector_id, cols_co2eq) %>% - pivot_longer(cols = cols_co2eq, - names_to = "quintile", - values_to = "co2eq_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2eq domestic and pivot long -cols_co2eq_domestic = c("q1_co2eq_domestic", "q2_co2eq_domestic", "q3_co2eq_domestic", "q4_co2eq_domestic", "q5_co2eq_domestic") -tmp_co2eq_domestic = dat_results %>% - select(year, geo, sector_id, cols_co2eq_domestic) %>% - pivot_longer(cols = cols_co2eq_domestic, - names_to = "quintile", - values_to = "co2eq_domestic_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2eq europe and pivot long -cols_co2eq_europe = c("q1_co2eq_europe", "q2_co2eq_europe", "q3_co2eq_europe", "q4_co2eq_europe", "q5_co2eq_europe") -tmp_co2eq_europe = dat_results %>% - select(year, geo, sector_id, cols_co2eq_europe) %>% - pivot_longer(cols = cols_co2eq_europe, - names_to = "quintile", - values_to = "co2eq_europe_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy use and pivot long -cols_energy = c("q1_energy","q2_energy","q3_energy","q4_energy","q5_energy") -tmp_energy = dat_results %>% - select(year, geo, sector_id, cols_energy) %>% - pivot_longer(cols = cols_energy, - names_to = "quintile", - values_to = "energy_use_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy domestic and pivot long -cols_energy_domestic = c("q1_energy_domestic","q2_energy_domestic","q3_energy_domestic","q4_energy_domestic","q5_energy_domestic") -tmp_energy_domestic = dat_results %>% - select(year, geo, sector_id, cols_energy_domestic) %>% - pivot_longer(cols = cols_energy_domestic, - names_to = "quintile", - values_to = "energy_use_domestic_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy europe and pivot long -cols_energy_europe = c("q1_energy_europe","q2_energy_europe","q3_energy_europe","q4_energy_europe","q5_energy_europe") -tmp_energy_europe = dat_results %>% - select(year, geo, sector_id, cols_energy_europe) %>% - pivot_longer(cols = cols_energy_europe, - names_to = "quintile", - values_to = "energy_use_europe_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -### TODO: also convert to other indicators to this format (as blocks above) -### TODO: left join all indicators back to "results_formated" like her with co2 -results_recombined = tmp_fd %>% - left_join(tmp_co2, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2_domestic, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2_europe, by = c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2eq, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2eq_domestic, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2eq_europe, by = c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_energy, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_energy_domestic, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_energy_europe, by = c("year", "geo", "sector_id", "quint")) - - - -# finally re-join aggregated sector IDs -results_formatted = results_recombined %>% - left_join(sector_mapping, by="sector_id") %>% - ungroup() %>% - select(-coicop_id) - -#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_rds(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi_pps_hh_no_rent.rds")) - - -#write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi_pps_ae.csv")) -#write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_ixi_pps_ae.rds")) - - -################################################### !!!! method 1 - PXP version - PPS HH NO RENT !!!! #################################################### -########################################################################################################################################################## -########################################################################################################################################################## - - -# Exiobase - pxp version - -years_exb_pxp = c(2005,2010) - -disaggregated_final_demand = NULL - -TIVs = NULL - -domestic_TIVs = NULL - -europe_TIVs = NULL - -national_fp = NULL - -national_territorial = NULL - -for (i in years_exb_pxp){ - year_current = i - - Exiobase_FD = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/FD_",year_current,"_pxp.csv"))[,-1] - - # select household final demand vectors for relevant countries - figure out how to soft code this - - AT = Exiobase_FD[,1] - BE = Exiobase_FD[,8] - BG = Exiobase_FD[,15] - CY = Exiobase_FD[,22] - CZ = Exiobase_FD[,29] - DE = Exiobase_FD[,36] - DK = Exiobase_FD[,43] - EE = Exiobase_FD[,50] - EL = Exiobase_FD[,78] - ES = Exiobase_FD[,57] - FI = Exiobase_FD[,64] - FR = Exiobase_FD[,71] - HR = Exiobase_FD[,85] - HU = Exiobase_FD[,92] - IE = Exiobase_FD[,99] - IT = Exiobase_FD[,106] - LT = Exiobase_FD[,113] - LU = Exiobase_FD[,120] - LV = Exiobase_FD[,127] - MT = Exiobase_FD[,134] - NL = Exiobase_FD[,141] - NO = Exiobase_FD[,288] - PL = Exiobase_FD[,148] - PT = Exiobase_FD[,155] - RO = Exiobase_FD[,162] - SE = Exiobase_FD[,169] - SI = Exiobase_FD[,176] - SK = Exiobase_FD[,183] - TR = Exiobase_FD[,274] - UK = Exiobase_FD[,190] - - Eurostat_countries = cbind(AT,BE,BG,CY,CZ,DE,DK,EE,EL,ES,FI,FR,HR,HU,IE,IT,LT,LU,LV,MT,NL,NO,PL,PT,RO,SE,SI,SK,TR,UK) - - # labels - - Exiobase_T_labels = read.csv(paste0(data_dir_income_stratified_footprints, "/data/Exiobase_T_labels_pxp_w_coicop_mapping_no_rent.csv")) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - - # hh fd with production sector labels - - hh_fd_with_production_sector_labels = cbind(Exiobase_T_labels,Eurostat_countries) %>% rename(geo = V1, sector = V2) - - # assumption of same purchase structure between quintiles of domestic and foreign final demand - - # replicate each cell of each country's hh final demand as many times as there are income groups in the HBS data - in this preliminary case:5 - - cells_repeat = data.frame(hh_fd_with_production_sector_labels %>% slice(rep(1:n(), each = 5))) - - quintiles = data.frame(rep(c("QUINTILE1","QUINTILE2","QUINTILE3","QUINTILE4","QUINTILE5"),200)) %>% rename_at(1,~"quintile") - - replicated = cbind(cells_repeat,quintiles) %>% rename(country_of_production = geo) - - # make fd data long - - replicated_long = replicated %>% gather(geo, value,-sector,-coicop,-quintile,-five_sectors,-country_of_production) - - year = as.character(rep(year_current,nrow(replicated_long))) - - replicated_long = cbind(year,replicated_long) - - - disaggregated_final_demand = rbind(disaggregated_final_demand, replicated_long) - - - # TIVs - - # CO2 - combustion - air - - Exiobase_TIV_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_combustion_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_combustion_air_", year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_domestic) - - Exiobase_TIV_europe_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_combustion_air_", year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_europe,TIV_CO2_not_europe) - - # CO2 - noncombustion - cement - air - - Exiobase_TIV_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_noncombustion_cement_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_noncombustion_cement_domestic) - - Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_noncombustion_cement_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_noncombustion_cement_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_noncombustion_cement_europe,TIV_CO2_noncombustion_cement_not_europe) - - # CO2 - noncombustion - lime - air - - Exiobase_TIV_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_noncombustion_lime_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_noncombustion_lime_domestic) - - Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_noncombustion_lime_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_noncombustion_lime_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_noncombustion_lime_europe,TIV_CO2_noncombustion_lime_not_europe) - - # CO2 - agriculture - peat decay - air - - Exiobase_TIV_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_agriculture_peatdecay_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_agriculture_peatdecay_domestic) - - Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_agriculture_peatdecay_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_agriculture_peatdecay_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_agriculture_peatdecay_europe,TIV_CO2_agriculture_peatdecay_not_europe) - - # CO2 - waste - biogenic - air - - Exiobase_TIV_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_biogenic_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_biogenic_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_waste_biogenic_domestic) - - Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_biogenic_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_waste_biogenic_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_waste_biogenic_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_waste_biogenic_europe,TIV_CO2_waste_biogenic_not_europe) - - # CO2 - waste - fossil - air - - Exiobase_TIV_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_co2_waste_fossil_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_waste_fossil_domestic) - - Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_waste_fossil_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_waste_fossil_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_waste_fossil_europe,TIV_CO2_waste_fossil_not_europe) - - - - # CH4 - combustion -air - - Exiobase_TIV_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_combustion_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_combustion_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_domestic) - - Exiobase_TIV_europe_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_combustion_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_europe,TIV_CH4_not_europe) - - # CH4 - noncombustion - gas - air - - Exiobase_TIV_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_gas_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_gas_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_gas_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_gas_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_gas_europe,TIV_CH4_noncombustion_gas_not_europe) - - # CH4 - noncombustion - oil - air - - Exiobase_TIV_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_oil_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_oil_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_oil_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_oil_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_oil_europe,TIV_CH4_noncombustion_oil_not_europe) - - # CH4 - noncombustion - anthracite - air - - Exiobase_TIV_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_anthracite_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_anthracite_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_anthracite_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_anthracite_europe,TIV_CH4_noncombustion_anthracite_not_europe) - - # CH4 - noncombustion - bituminouscoal - air - - Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_bituminouscoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_bituminouscoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_bituminouscoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_bituminouscoal_europe,TIV_CH4_noncombustion_bituminouscoal_not_europe) - - # CH4 - noncombustion - cokingcoal - air - - Exiobase_TIV_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_cokingcoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_cokingcoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_cokingcoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_cokingcoal_europe,TIV_CH4_noncombustion_cokingcoal_not_europe) - - # CH4 - noncombustion - lignite - air - - Exiobase_TIV_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_lignite_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_lignite_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_lignite_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_lignite_europe,TIV_CH4_noncombustion_lignite_not_europe) - - # CH4 - noncombustion - subbituminouscoal - air - - Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_subbituminouscoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_subbituminouscoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_subbituminouscoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_subbituminouscoal_europe,TIV_CH4_noncombustion_subbituminouscoal_not_europe) - - # CH4 - noncombustion - oilrefinery - air - - Exiobase_TIV_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_oilrefinery_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_oilrefinery_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_oilrefinery_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_oilrefinery_europe,TIV_CH4_noncombustion_oilrefinery_not_europe) - - # CH4 - agriculture - air - - Exiobase_TIV_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_agriculture_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_agriculture_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_agriculture_domestic) - - Exiobase_TIV_europe_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_agriculture_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_agriculture_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_agriculture_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_agriculture_europe,TIV_CH4_agriculture_not_europe) - - # CH4 - waste - air - - Exiobase_TIV_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ch4_CO2eq_waste_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_waste_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_waste_domestic) - - Exiobase_TIV_europe_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ch4_CO2eq_waste_air_", year_current, "_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_waste_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_waste_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_waste_europe,TIV_CH4_waste_not_europe) - - - - # N2O - combustion - air - - Exiobase_TIV_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_n2o_CO2eq_combustion_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_N2O_domestic) - - Exiobase_TIV_europe_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_N2O_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_N2O_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_N2O_europe,TIV_N2O_not_europe) - - # N2O - agriculture - air - - Exiobase_TIV_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_n2o_CO2eq_agriculture_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_N2O_agriculture_domestic) - - Exiobase_TIV_europe_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_N2O_agriculture_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_N2O_agriculture_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_N2O_agriculture_europe,TIV_N2O_agriculture_not_europe) - - # SF6 - air - - Exiobase_TIV_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_sf6_CO2eq_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_SF6_domestic) - - Exiobase_TIV_europe_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_SF6_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_SF6_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_SF6_europe,TIV_SF6_not_europe) - - # HFC - air - - Exiobase_TIV_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_hfc_CO2eq_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_HFC_domestic) - - Exiobase_TIV_europe_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_HFC_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_HFC_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_HFC_europe,TIV_HFC_not_europe) - - # PFC - air - - Exiobase_TIV_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_pfc_CO2eq_air_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_PFC_domestic) - - Exiobase_TIV_europe_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_PFC_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_PFC_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_PFC_europe,TIV_PFC_not_europe) - - # Energy use - - Exiobase_TIV_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_energy_carrier_use_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_energy_carrier_use_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_energy_domestic) - - Exiobase_TIV_europe_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_energy_carrier_use_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_energy_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_energy_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_energy_europe,TIV_energy_not_europe) - - # biomass - - Exiobase_TIV_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_biomass_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_biomass_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_biomass_domestic) - - Exiobase_TIV_europe_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_biomass_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_biomass_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_biomass_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_biomass_europe,TIV_biomass_not_europe) - - # construction materials - - Exiobase_TIV_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_const_materials_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_const_materials_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_const_materials_domestic) - - Exiobase_TIV_europe_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_const_materials_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_const_materials_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_const_materials_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_const_materials_europe,TIV_const_materials_not_europe) - - # fossil fuels - - Exiobase_TIV_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ffuels_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ffuels_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_ffuels_domestic) - - Exiobase_TIV_europe_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ffuels_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_ffuels_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_ffuels_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_ffuels_europe,TIV_ffuels_not_europe) - - # ores - - Exiobase_TIV_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_ores_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ores_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_ores_domestic) - - Exiobase_TIV_europe_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_ores_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_ores_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_ores_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_ores_europe,TIV_ores_not_europe) - - # cropland - - Exiobase_TIV_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_cropland_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_cropland_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_cropland_domestic) - - Exiobase_TIV_europe_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_cropland_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_cropland_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_cropland_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_cropland_europe,TIV_cropland_not_europe) - - # forest land - - Exiobase_TIV_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_forest_land_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_forest_land_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_forest_land_domestic) - - Exiobase_TIV_europe_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_forest_land_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_forest_land_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_forest_land_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_forest_land_europe,TIV_forest_land_not_europe) - - # pasture land - - Exiobase_TIV_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_pasture_land_",year_current,"_pxp.csv"))[,-1] - - Exiobase_TIV_country_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_pasture_land_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_pasture_land_domestic) - - Exiobase_TIV_europe_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_pxp/TIV_country_breakdown_pasture_land_",year_current,"_pxp.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_pasture_land_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_pasture_land_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_pasture_land_europe,TIV_pasture_land_not_europe) - - - # join with labels - - TIV_with_labels = cbind(Exiobase_T_labels, - t(Exiobase_TIV_co2_bp), - t(Exiobase_TIV_co2_noncombustion_cement_bp), - t(Exiobase_TIV_co2_noncombustion_lime_bp), - t(Exiobase_TIV_co2_agriculture_peatdecay_bp), - t(Exiobase_TIV_co2_waste_biogenic_bp), - t(Exiobase_TIV_co2_waste_fossil_bp), - t(Exiobase_TIV_ch4_bp), - t(Exiobase_TIV_ch4_noncombustion_gas_bp), - t(Exiobase_TIV_ch4_noncombustion_oil_bp), - t(Exiobase_TIV_ch4_noncombustion_anthracite_bp), - t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp), - t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp), - t(Exiobase_TIV_ch4_noncombustion_lignite_bp), - t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp), - t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp), - t(Exiobase_TIV_ch4_agriculture_bp), - t(Exiobase_TIV_ch4_waste_bp), - t(Exiobase_TIV_n2o_bp), - t(Exiobase_TIV_n2o_agriculture_bp), - t(Exiobase_TIV_sf6_bp), - t(Exiobase_TIV_hfc_bp), - t(Exiobase_TIV_pfc_bp), - t(Exiobase_TIV_energy_use_bp), - t(Exiobase_TIV_biomass_bp), - t(Exiobase_TIV_const_materials_bp), - t(Exiobase_TIV_ffuels_bp), - t(Exiobase_TIV_ores_bp), - t(Exiobase_TIV_cropland_bp), - t(Exiobase_TIV_forest_land_bp), - t(Exiobase_TIV_pasture_land_bp)) %>% - rename(TIV_CO2 = "t(Exiobase_TIV_co2_bp)", - TIV_CO2_noncombustion_cement = "t(Exiobase_TIV_co2_noncombustion_cement_bp)", - TIV_CO2_noncombustion_lime = "t(Exiobase_TIV_co2_noncombustion_lime_bp)", - TIV_CO2_agriculture_peatdecay = "t(Exiobase_TIV_co2_agriculture_peatdecay_bp)", - TIV_CO2_waste_biogenic = "t(Exiobase_TIV_co2_waste_biogenic_bp)", - TIV_CO2_waste_fossil = "t(Exiobase_TIV_co2_waste_fossil_bp)", - TIV_CH4 = "t(Exiobase_TIV_ch4_bp)", - TIV_CH4_noncombustion_gas = "t(Exiobase_TIV_ch4_noncombustion_gas_bp)", - TIV_CH4_noncombustion_oil = "t(Exiobase_TIV_ch4_noncombustion_oil_bp)", - TIV_CH4_noncombustion_anthracite = "t(Exiobase_TIV_ch4_noncombustion_anthracite_bp)", - TIV_CH4_noncombustion_bituminouscoal = "t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp)", - TIV_CH4_noncombustion_cokingcoal = "t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp)", - TIV_CH4_noncombustion_lignite = "t(Exiobase_TIV_ch4_noncombustion_lignite_bp)", - TIV_CH4_noncombustion_subbituminouscoal = "t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp)", - TIV_CH4_noncombustion_oilrefinery = "t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp)", - TIV_CH4_agriculture = "t(Exiobase_TIV_ch4_agriculture_bp)", - TIV_CH4_waste = "t(Exiobase_TIV_ch4_waste_bp)", - TIV_N2O = "t(Exiobase_TIV_n2o_bp)", - TIV_N2O_agriculture = "t(Exiobase_TIV_n2o_agriculture_bp)", - TIV_SF6 = "t(Exiobase_TIV_sf6_bp)", - TIV_HFC = "t(Exiobase_TIV_hfc_bp)", - TIV_PFC = "t(Exiobase_TIV_pfc_bp)", - TIV_energy = "t(Exiobase_TIV_energy_use_bp)", - TIV_biomass = "t(Exiobase_TIV_biomass_bp)", - TIV_const_materials = "t(Exiobase_TIV_const_materials_bp)", - TIV_ffuels = "t(Exiobase_TIV_ffuels_bp)", - TIV_ores = "t(Exiobase_TIV_ores_bp)", - TIV_cropland = "t(Exiobase_TIV_cropland_bp)", - TIV_forest_land = "t(Exiobase_TIV_forest_land_bp)", - TIV_pasture_land = "t(Exiobase_TIV_pasture_land_bp)") %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year = as.character(rep(year_current,nrow(TIV_with_labels))) - - look = cbind(year,TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2) - - - TIVs = rbind(TIVs,look) - - - # join domestic_TIVs with labels - - domestic_TIV_with_labels = cbind(Exiobase_T_labels, - Exiobase_TIV_country_breakdown_co2_bp, - Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_waste_fossil_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_agriculture_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_waste_bp %>% select(-country), - Exiobase_TIV_country_breakdown_n2o_bp %>% select(-country), - Exiobase_TIV_country_breakdown_n2o_agriculture_bp %>% select(-country), - Exiobase_TIV_country_breakdown_sf6_bp %>% select(-country), - Exiobase_TIV_country_breakdown_hfc_bp %>% select(-country), - Exiobase_TIV_country_breakdown_pfc_bp %>% select(-country), - Exiobase_TIV_country_breakdown_energy_use_bp %>% select(-country), - Exiobase_TIV_country_breakdown_biomass_bp %>% select(-country), - Exiobase_TIV_country_breakdown_const_materials_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ffuels_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ores_bp %>% select(-country), - Exiobase_TIV_country_breakdown_cropland_bp %>% select(-country), - Exiobase_TIV_country_breakdown_forest_land_bp %>% select(-country), - Exiobase_TIV_country_breakdown_pasture_land_bp %>% select(-country)) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK"), - country = dplyr::recode(country, "GR" = "EL", "GB" = "UK")) - - year_domestic = as.character(rep(year_current,nrow(domestic_TIV_with_labels))) - - look_domestic = cbind(year_domestic,domestic_TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2, geo = country, year = year_domestic) %>% - mutate(TIV_CO2_domestic = as.numeric(TIV_CO2_domestic), - TIV_CO2_noncombustion_cement_domestic = as.numeric(TIV_CO2_noncombustion_cement_domestic), - TIV_CO2_noncombustion_lime_domestic = as.numeric(TIV_CO2_noncombustion_lime_domestic), - TIV_CO2_agriculture_peatdecay_domestic = as.numeric(TIV_CO2_agriculture_peatdecay_domestic), - TIV_CO2_waste_biogenic_domestic = as.numeric(TIV_CO2_waste_biogenic_domestic), - TIV_CO2_waste_fossil_domestic = as.numeric(TIV_CO2_waste_fossil_domestic), - TIV_CH4_domestic = as.numeric(TIV_CH4_domestic), - TIV_CH4_noncombustion_gas_domestic = as.numeric(TIV_CH4_noncombustion_gas_domestic), - TIV_CH4_noncombustion_oil_domestic = as.numeric(TIV_CH4_noncombustion_oil_domestic), - TIV_CH4_noncombustion_anthracite_domestic = as.numeric(TIV_CH4_noncombustion_anthracite_domestic), - TIV_CH4_noncombustion_bituminouscoal_domestic = as.numeric(TIV_CH4_noncombustion_bituminouscoal_domestic), - TIV_CH4_noncombustion_cokingcoal_domestic = as.numeric(TIV_CH4_noncombustion_cokingcoal_domestic), - TIV_CH4_noncombustion_lignite_domestic = as.numeric(TIV_CH4_noncombustion_lignite_domestic), - TIV_CH4_noncombustion_subbituminouscoal_domestic = as.numeric(TIV_CH4_noncombustion_subbituminouscoal_domestic), - TIV_CH4_noncombustion_oilrefinery_domestic = as.numeric(TIV_CH4_noncombustion_oilrefinery_domestic), - TIV_CH4_agriculture_domestic = as.numeric(TIV_CH4_agriculture_domestic), - TIV_CH4_waste_domestic = as.numeric(TIV_CH4_waste_domestic), - TIV_N2O_domestic = as.numeric(TIV_N2O_domestic), - TIV_N2O_agriculture_domestic = as.numeric(TIV_N2O_agriculture_domestic), - TIV_SF6_domestic = as.numeric(TIV_SF6_domestic), - TIV_HFC_domestic = as.numeric(TIV_HFC_domestic), - TIV_PFC_domestic = as.numeric(TIV_PFC_domestic), - TIV_energy_domestic = as.numeric(TIV_energy_domestic), - TIV_biomass_domestic = as.numeric(TIV_biomass_domestic), - TIV_const_materials_domestic = as.numeric(TIV_const_materials_domestic), - TIV_ffuels_domestic = as.numeric(TIV_ffuels_domestic), - TIV_ores_domestic = as.numeric(TIV_ores_domestic), - TIV_cropland_domestic = as.numeric(TIV_cropland_domestic), - TIV_forest_land_domestic = as.numeric(TIV_forest_land_domestic), - TIV_pasture_land_domestic = as.numeric(TIV_pasture_land_domestic)) - - domestic_TIVs = rbind(domestic_TIVs, look_domestic) - - # europe TIVs with labels - - europe_TIV_with_labels = cbind(Exiobase_T_labels, - Exiobase_TIV_europe_breakdown_co2_bp, - Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp, - Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp, - Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp, - Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp, - Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp, - Exiobase_TIV_europe_breakdown_ch4_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp, - Exiobase_TIV_europe_breakdown_ch4_agriculture_bp, - Exiobase_TIV_europe_breakdown_ch4_waste_bp, - Exiobase_TIV_europe_breakdown_n2o_bp, - Exiobase_TIV_europe_breakdown_n2o_agriculture_bp, - Exiobase_TIV_europe_breakdown_sf6_bp, - Exiobase_TIV_europe_breakdown_hfc_bp, - Exiobase_TIV_europe_breakdown_pfc_bp, - Exiobase_TIV_europe_breakdown_energy_use_bp, - Exiobase_TIV_europe_breakdown_biomass_bp, - Exiobase_TIV_europe_breakdown_const_materials_bp, - Exiobase_TIV_europe_breakdown_ffuels_bp, - Exiobase_TIV_europe_breakdown_ores_bp, - Exiobase_TIV_europe_breakdown_cropland_bp, - Exiobase_TIV_europe_breakdown_forest_land_bp, - Exiobase_TIV_europe_breakdown_pasture_land_bp) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year_europe = as.character(rep(year_current,nrow(europe_TIV_with_labels))) - - look_europe = cbind(year_europe,europe_TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2, year = year_europe) %>% - mutate(TIV_CO2_europe = as.numeric(TIV_CO2_europe), - TIV_CO2_noncombustion_cement_europe = as.numeric(TIV_CO2_noncombustion_cement_europe), - TIV_CO2_noncombustion_lime_europe = as.numeric(TIV_CO2_noncombustion_lime_europe), - TIV_CO2_agriculture_peatdecay_europe = as.numeric(TIV_CO2_agriculture_peatdecay_europe), - TIV_CO2_waste_biogenic_europe = as.numeric(TIV_CO2_waste_biogenic_europe), - TIV_CO2_waste_fossil_europe = as.numeric(TIV_CO2_waste_fossil_europe), - TIV_CH4_europe = as.numeric(TIV_CH4_europe), - TIV_CH4_noncombustion_gas_europe = as.numeric(TIV_CH4_noncombustion_gas_europe), - TIV_CH4_noncombustion_oil_europe = as.numeric(TIV_CH4_noncombustion_oil_europe), - TIV_CH4_noncombustion_anthracite_europe = as.numeric(TIV_CH4_noncombustion_anthracite_europe), - TIV_CH4_noncombustion_bituminouscoal_europe = as.numeric(TIV_CH4_noncombustion_bituminouscoal_europe), - TIV_CH4_noncombustion_cokingcoal_europe = as.numeric(TIV_CH4_noncombustion_cokingcoal_europe), - TIV_CH4_noncombustion_lignite_europe = as.numeric(TIV_CH4_noncombustion_lignite_europe), - TIV_CH4_noncombustion_subbituminouscoal_europe = as.numeric(TIV_CH4_noncombustion_subbituminouscoal_europe), - TIV_CH4_noncombustion_oilrefinery_europe = as.numeric(TIV_CH4_noncombustion_oilrefinery_europe), - TIV_CH4_agriculture_europe = as.numeric(TIV_CH4_agriculture_europe), - TIV_CH4_waste_europe = as.numeric(TIV_CH4_waste_europe), - TIV_N2O_europe = as.numeric(TIV_N2O_europe), - TIV_N2O_agriculture_europe = as.numeric(TIV_N2O_agriculture_europe), - TIV_SF6_europe = as.numeric(TIV_SF6_europe), - TIV_HFC_europe = as.numeric(TIV_HFC_europe), - TIV_PFC_europe = as.numeric(TIV_PFC_europe), - TIV_energy_europe = as.numeric(TIV_energy_europe), - TIV_biomass_europe = as.numeric(TIV_biomass_europe), - TIV_const_materials_europe = as.numeric(TIV_const_materials_europe), - TIV_ffuels_europe = as.numeric(TIV_ffuels_europe), - TIV_ores_europe = as.numeric(TIV_ores_europe), - TIV_cropland_europe = as.numeric(TIV_cropland_europe), - TIV_forest_land_europe = as.numeric(TIV_forest_land_europe), - TIV_pasture_land_europe = as.numeric(TIV_pasture_land_europe)) - - europe_TIVs = rbind(europe_TIVs, look_europe) - - - # total national footprints - - # FD labels - - Exiobase_FD_labels = as.data.frame(t(read.csv(paste0(data_dir_exiobase, "/Exiobase_FD_labels_pxp.csv")))[-1,-3]) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - national_CO2_footprints = Exiobase_FD * t(Exiobase_TIV_co2_bp) - - national_CO2_noncombustion_cement_footprints = Exiobase_FD * t(Exiobase_TIV_co2_noncombustion_cement_bp) - - national_CO2_noncombustion_lime_footprints = Exiobase_FD * t(Exiobase_TIV_co2_noncombustion_lime_bp) - - national_CO2_agriculture_peatdecay_footprints = Exiobase_FD * t(Exiobase_TIV_co2_agriculture_peatdecay_bp) - - national_CO2_waste_biogenic_footprints = Exiobase_FD * t(Exiobase_TIV_co2_waste_biogenic_bp) - - national_CO2_waste_fossil_footprints = Exiobase_FD * t(Exiobase_TIV_co2_waste_fossil_bp) - - national_CH4_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_bp) - - national_CH4_noncombustion_gas_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_gas_bp) - - national_CH4_noncombustion_oil_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_oil_bp) - - national_CH4_noncombustion_anthracite_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_anthracite_bp) - - national_CH4_noncombustion_bituminouscoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp) - - national_CH4_noncombustion_cokingcoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp) - - national_CH4_noncombustion_lignite_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_lignite_bp) - - national_CH4_noncombustion_subbituminouscoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp) - - national_CH4_noncombustion_oilrefinery_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp) - - national_CH4_agriculture_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_agriculture_bp) - - national_CH4_waste_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_waste_bp) - - national_N2O_footprints = Exiobase_FD * t(Exiobase_TIV_n2o_bp) - - national_N2O_agriculture_footprints = Exiobase_FD * t(Exiobase_TIV_n2o_agriculture_bp) - - national_SF6_footprints = Exiobase_FD * t(Exiobase_TIV_sf6_bp) - - national_HFC_footprints = Exiobase_FD * t(Exiobase_TIV_hfc_bp) - - national_PFC_footprints = Exiobase_FD * t(Exiobase_TIV_pfc_bp) - - national_energy_footprints = Exiobase_FD * t(Exiobase_TIV_energy_use_bp) - - national_biomass_footprints = Exiobase_FD * t(Exiobase_TIV_biomass_bp) - - national_const_materials_footprints = Exiobase_FD * t(Exiobase_TIV_const_materials_bp) - - national_ffuels_footprints = Exiobase_FD * t(Exiobase_TIV_ffuels_bp) - - national_ores_footprints = Exiobase_FD * t(Exiobase_TIV_ores_bp) - - national_cropland_footprints = Exiobase_FD * t(Exiobase_TIV_cropland_bp) - - national_forest_land_footprints = Exiobase_FD * t(Exiobase_TIV_forest_land_bp) - - national_pasture_land_footprints = Exiobase_FD * t(Exiobase_TIV_pasture_land_bp) - - - # together - - national_footprints_w_labels = cbind(Exiobase_FD_labels, - rowSums(t(national_CO2_footprints)), - rowSums(t(national_CO2_noncombustion_cement_footprints)), - rowSums(t(national_CO2_noncombustion_lime_footprints)), - rowSums(t(national_CO2_agriculture_peatdecay_footprints)), - rowSums(t(national_CO2_waste_biogenic_footprints)), - rowSums(t(national_CO2_waste_fossil_footprints)), - rowSums(t(national_CH4_footprints)), - rowSums(t(national_CH4_noncombustion_gas_footprints)), - rowSums(t(national_CH4_noncombustion_oil_footprints)), - rowSums(t(national_CH4_noncombustion_anthracite_footprints)), - rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints)), - rowSums(t(national_CH4_noncombustion_cokingcoal_footprints)), - rowSums(t(national_CH4_noncombustion_lignite_footprints)), - rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints)), - rowSums(t(national_CH4_noncombustion_oilrefinery_footprints)), - rowSums(t(national_CH4_agriculture_footprints)), - rowSums(t(national_CH4_waste_footprints)), - rowSums(t(national_N2O_footprints)), - rowSums(t(national_N2O_agriculture_footprints)), - rowSums(t(national_SF6_footprints)), - rowSums(t(national_HFC_footprints)), - rowSums(t(national_PFC_footprints)), - rowSums(t(national_energy_footprints)), - rowSums(t(national_biomass_footprints)), - rowSums(t(national_const_materials_footprints)), - rowSums(t(national_ffuels_footprints)), - rowSums(t(national_ores_footprints)), - rowSums(t(national_cropland_footprints)), - rowSums(t(national_forest_land_footprints)), - rowSums(t(national_pasture_land_footprints))) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year_national_fp = as.character(rep(year_current,nrow(national_footprints_w_labels))) - - - # direct FD emissions - - direct_FD_extensions = read.csv(paste0(data_dir_exiobase, "/IOT_", year_current, "_pxp/satellite/F_hh.csv", sep = ""),row.names=NULL,as.is=TRUE)[3:1106,3:345] - direct_FD_extensions[is.na(direct_FD_extensions)]=0 - direct_FD_extensions = mapply(direct_FD_extensions, FUN = as.numeric) - direct_FD_extensions = matrix(data=direct_FD_extensions,ncol=343,nrow=1104) - - direct_FD_co2 = direct_FD_extensions[24,] - direct_FD_co2_noncombustion_cement = direct_FD_extensions[93,] - direct_FD_co2_noncombustion_lime = direct_FD_extensions[94,] - direct_FD_co2_agriculture_peatdecay = direct_FD_extensions[428,] - direct_FD_co2_waste_biogenic = direct_FD_extensions[438,] - direct_FD_co2_waste_fossil = direct_FD_extensions[439,] - direct_FD_ch4 = direct_FD_extensions[25,]*28 - direct_FD_ch4_noncombustion_gas = direct_FD_extensions[68,]*28 - direct_FD_ch4_noncombustion_oil = direct_FD_extensions[69,]*28 - direct_FD_ch4_noncombustion_anthracite = direct_FD_extensions[70,]*28 - direct_FD_ch4_noncombustion_bituminouscoal = direct_FD_extensions[71,]*28 - direct_FD_ch4_noncombustion_cokingcoal = direct_FD_extensions[72,]*28 - direct_FD_ch4_noncombustion_lignite = direct_FD_extensions[73,]*28 - direct_FD_ch4_noncombustion_subbituminouscoal = direct_FD_extensions[74,]*28 - direct_FD_ch4_noncombustion_oilrefinery = direct_FD_extensions[75,]*28 - direct_FD_ch4_agriculture = direct_FD_extensions[427,]*28 - direct_FD_ch4_waste = direct_FD_extensions[436,]*28 - direct_FD_n2o = direct_FD_extensions[26,]*265 - direct_FD_n2o_agriculture = direct_FD_extensions[430,]*265 - direct_FD_sf6 = direct_FD_extensions[424,]*23500 - direct_FD_hfc = direct_FD_extensions[425,] - direct_FD_pfc = direct_FD_extensions[426,] - direct_FD_energy = direct_FD_extensions[470,] - direct_FD_biomass = colSums(direct_FD_extensions[c(471:499,501,522:688),]) - direct_FD_const_materials = colSums(direct_FD_extensions[514:521,]) - direct_FD_ffuels = direct_FD_extensions[500,] - direct_FD_ores = colSums(direct_FD_extensions[502:513,]) - direct_FD_cropland = colSums(direct_FD_extensions[447:459,]) - direct_FD_forest_land = colSums(direct_FD_extensions[c(460,466),]) - direct_FD_pasture_land = colSums(direct_FD_extensions[462:464,]) - - - direct_FD_fp = data.frame(direct_FD_co2, - direct_FD_co2_noncombustion_cement, - direct_FD_co2_noncombustion_lime, - direct_FD_co2_agriculture_peatdecay, - direct_FD_co2_waste_biogenic, - direct_FD_co2_waste_fossil, - direct_FD_ch4, - direct_FD_ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_oilrefinery, - direct_FD_ch4_agriculture, - direct_FD_ch4_waste, - direct_FD_n2o, - direct_FD_n2o_agriculture, - direct_FD_sf6, - direct_FD_hfc, - direct_FD_pfc, - direct_FD_energy, - direct_FD_biomass, - direct_FD_const_materials, - direct_FD_ffuels, - direct_FD_ores, - direct_FD_cropland, - direct_FD_forest_land, - direct_FD_pasture_land) - - look_national_fp = as.data.frame(cbind(year_national_fp, - national_footprints_w_labels, - direct_FD_fp)) %>% - rename(year = year_national_fp, - geo = V1, - fd_category = V2, - co2 = "rowSums(t(national_CO2_footprints))", - co2_noncombustion_cement = "rowSums(t(national_CO2_noncombustion_cement_footprints))", - co2_noncombustion_lime = "rowSums(t(national_CO2_noncombustion_lime_footprints))", - co2_agriculture_peatdecay = "rowSums(t(national_CO2_agriculture_peatdecay_footprints))", - co2_waste_biogenic = "rowSums(t(national_CO2_waste_biogenic_footprints))", - co2_waste_fossil = "rowSums(t(national_CO2_waste_fossil_footprints))", - ch4 = "rowSums(t(national_CH4_footprints))", - ch4_noncombustion_gas = "rowSums(t(national_CH4_noncombustion_gas_footprints))", - ch4_noncombustion_oil = "rowSums(t(national_CH4_noncombustion_oil_footprints))", - ch4_noncombustion_anthracite = "rowSums(t(national_CH4_noncombustion_anthracite_footprints))", - ch4_noncombustion_bituminouscoal = "rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints))", - ch4_noncombustion_cokingcoal = "rowSums(t(national_CH4_noncombustion_cokingcoal_footprints))", - ch4_noncombustion_lignite = "rowSums(t(national_CH4_noncombustion_lignite_footprints))", - ch4_noncombustion_subbituminouscoal = "rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints))", - ch4_noncombustion_oilrefinery = "rowSums(t(national_CH4_noncombustion_oilrefinery_footprints))", - ch4_agriculture = "rowSums(t(national_CH4_agriculture_footprints))", - ch4_waste = "rowSums(t(national_CH4_waste_footprints))", - n2o = "rowSums(t(national_N2O_footprints))", - n2o_agriculture = "rowSums(t(national_N2O_agriculture_footprints))", - sf6 = "rowSums(t(national_SF6_footprints))", - hfc = "rowSums(t(national_HFC_footprints))", - pfc = "rowSums(t(national_PFC_footprints))", - energy = "rowSums(t(national_energy_footprints))", - biomass = "rowSums(t(national_biomass_footprints))", - const_materials = "rowSums(t(national_const_materials_footprints))", - ffuels = "rowSums(t(national_ffuels_footprints))", - ores = "rowSums(t(national_ores_footprints))", - cropland = "rowSums(t(national_cropland_footprints))", - forest_land = "rowSums(t(national_forest_land_footprints))", - pasture_land = "rowSums(t(national_pasture_land_footprints))") %>% - select(year, - geo, - fd_category, - co2, - direct_FD_co2, - co2_noncombustion_cement, - direct_FD_co2_noncombustion_cement, - co2_noncombustion_lime, - direct_FD_co2_noncombustion_lime, - co2_agriculture_peatdecay, - direct_FD_co2_agriculture_peatdecay, - co2_waste_biogenic, - direct_FD_co2_waste_biogenic, - co2_waste_fossil, - direct_FD_co2_waste_fossil, - ch4, - direct_FD_ch4, - ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_gas, - ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_oil, - ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_anthracite, - ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_bituminouscoal, - ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_cokingcoal, - ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_lignite, - ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_subbituminouscoal, - ch4_noncombustion_oilrefinery, - direct_FD_ch4_noncombustion_oilrefinery, - ch4_agriculture, - direct_FD_ch4_agriculture, - ch4_waste, - direct_FD_ch4_waste, - n2o, - direct_FD_n2o, - n2o_agriculture, - direct_FD_n2o_agriculture, - sf6, - direct_FD_sf6, - hfc, - direct_FD_hfc, - pfc, - direct_FD_pfc, - energy, - direct_FD_energy, - biomass, - direct_FD_biomass, - const_materials, - direct_FD_const_materials, - ffuels, - direct_FD_ffuels, - ores, - direct_FD_ores, - cropland, - direct_FD_cropland, - forest_land, - direct_FD_forest_land, - pasture_land, - direct_FD_pasture_land) - - - national_fp = rbind(national_fp, look_national_fp) - - # national territorial - - satellite = read.csv(paste0(data_dir_exiobase, "/IOT_", year_current, "_pxp/satellite/satellite_",year_current,"_pxp.csv"))[,-1] - - - CO2_combustion_air = satellite[24,] - - CO2_noncombustion_cement_air = satellite[93,] - - CO2_noncombustion_lime_air = satellite[94,] - - CO2_agriculture_peatdecay_air = satellite[428,] - - CO2_waste_biogenic_air = satellite[438,] - - CO2_waste_fossil_air = satellite[439,] - - CH4_combustion_air = satellite[25,] - CH4_combustion_air = CH4_combustion_air*28 - - CH4_noncombustion_gas_air = satellite[68,] - CH4_noncombustion_gas_air = CH4_noncombustion_gas_air*28 - - CH4_noncombustion_oil_air = satellite[69,] - CH4_noncombustion_oil_air = CH4_noncombustion_oil_air*28 - - CH4_noncombustion_anthracite_air = satellite[70,] - CH4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air*28 - - CH4_noncombustion_bituminouscoal_air = satellite[71,] - CH4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air*28 - - CH4_noncombustion_cokingcoal_air = satellite[72,] - CH4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air*28 - - CH4_noncombustion_lignite_air = satellite[73,] - CH4_noncombustion_lignite_air = CH4_noncombustion_lignite_air*28 - - CH4_noncombustion_subbituminouscoal_air = satellite[74,] - CH4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air*28 - - CH4_noncombustion_oilrefinery_air = satellite[75,] - CH4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air*28 - - CH4_agriculture_air = satellite[427,] - CH4_agriculture_air = CH4_agriculture_air*28 - - CH4_waste_air = satellite[436,] - CH4_waste_air = CH4_waste_air*28 - - N2O_combustion_air = satellite[26,] - N2O_combustion_air = N2O_combustion_air*265 - - N2O_agriculture_air = satellite[430,] - N2O_agriculture_air = N2O_agriculture_air*265 - - SF6_air = satellite[424,] - SF6_air = SF6_air*23500 - - HFC_air = satellite[425,] - - PFC_air = satellite[426,] - - energy_carrier_use = satellite[470,] - - biomass = as.data.frame(colSums(satellite[c(471:499,501,522:688),])) - - ores = as.data.frame(colSums(satellite[502:513,])) - - const_materials = as.data.frame(colSums(satellite[514:521,])) - - ffuels = satellite[500,] - - cropland = as.data.frame(colSums(satellite[447:459,])) - - pasture_land = as.data.frame(colSums(satellite[462:464,])) - - forest_land = as.data.frame(colSums(satellite[c(460,466),])) - - - territorial = data.frame(t(CO2_combustion_air), - t(CO2_noncombustion_cement_air), - t(CO2_noncombustion_lime_air), - t(CO2_agriculture_peatdecay_air), - t(CO2_waste_biogenic_air), - t(CO2_waste_fossil_air), - t(CH4_combustion_air), - t(CH4_noncombustion_gas_air), - t(CH4_noncombustion_oil_air), - t(CH4_noncombustion_anthracite_air), - t(CH4_noncombustion_bituminouscoal_air), - t(CH4_noncombustion_cokingcoal_air), - t(CH4_noncombustion_lignite_air), - t(CH4_noncombustion_subbituminouscoal_air), - t(CH4_noncombustion_oilrefinery_air), - t(CH4_agriculture_air), - t(CH4_waste_air), - t(N2O_combustion_air), - t(N2O_agriculture_air), - t(SF6_air), - t(HFC_air), - t(PFC_air), - t(energy_carrier_use), - biomass, - ores, - const_materials, - t(ffuels), - cropland, - pasture_land, - forest_land) %>% - rename(CO2 = 1, - CO2_noncombustion_cement = 2, - CO2_noncombustion_lime = 3, - CO2_agriculture_peatdecay = 4, - CO2_waste_biogenic = 5, - CO2_waste_fossil = 6, - CH4 = 7, - CH4_noncombustion_gas = 8, - CH4_noncombustion_oil = 9, - CH4_noncombustion_anthracite = 10, - CH4_noncombustion_bituminouscoal = 11, - CH4_noncombustion_cokingcoal = 12, - CH4_noncombustion_lignite = 13, - CH4_noncombustion_subbituminouscoal = 14, - CH4_noncombustion_oilrefinery = 15, - CH4_agriculture = 16, - CH4_waste = 17, - N2O = 18, - N2O_agriculture = 19, - SF6 = 20, - HFC = 21, PFC = 22, energy = 23, - biomass = 24, ores = 25, - const_materials = 26, ffuels = 27, - cropland = 28, pasture_land = 29, - forest_land = 30) - - year_territorial = as.character(rep(year_current,nrow(territorial))) - - look_territorial = as.data.frame(cbind(year_territorial, - Exiobase_T_labels, - territorial)) %>% - rename(year = year_territorial, - geo = V1, - sector = V2) %>% - select(-coicop,-five_sectors) - - national_territorial = rbind(national_territorial, look_territorial) - - -} - -write.csv(national_territorial, paste0(data_dir_income_stratified_footprints, "/national_territorial_pxp.csv")) -write_rds(national_territorial, paste0(data_dir_income_stratified_footprints, "/national_territorial_pxp.rds")) - - -write.csv(national_fp, paste0(data_dir_income_stratified_footprints, "/national_fp_pxp.csv")) -write_rds(national_fp, paste0(data_dir_income_stratified_footprints, "/national_fp_pxp.rds")) - -# calculate quintile shares within each sector -shares = join_expenditures %>% - group_by(coicop,geo,year) %>% - mutate(share = pps_coicop/sum(pps_coicop)) - -# pre-processing - -fd_exiobase = disaggregated_final_demand %>% - left_join(shares, by = c("year","geo","coicop","quintile")) %>% - mutate(disaggregated_fd = value*share) %>% - select(year,geo,quintile,country_of_production,sector,coicop,disaggregated_fd) %>% - spread(quintile,disaggregated_fd) - -# direct from FD - to go back to results without direct FD fp, do not run this next chunk and do not bind_rows with 'results' - -env_ac_pefasu_no_TR = read_csv(paste0(data_dir_income_stratified_footprints, "/data/env_ac_pefasu_1_Data.csv")) %>% - filter(TIME == 2015) %>% - mutate(geo = dplyr::recode(GEO,"Austria" = "AT", - "Belgium" = "BE", - "Cyprus" = "CY", - "Czechia" = "CZ", - "Denmark" = "DK", - "Estonia" = "EE", - "Finland" = "FI", - "France" = "FR", - "Germany (until 1990 former territory of the FRG)" = "DE", - "Greece" = "EL", - "Hungary" = "HU", - "Ireland" = "IE", - "Italy" = "IT", - "Latvia" = "LV", - "Lithuania" = "LT", - "Luxembourg" = "LU", - "Malta" = "MT", - "Netherlands" = "NL", - "Norway" = "NO", - "Poland" = "PL", - "Portugal" = "PT", - "Romania" = "RO", - "Slovakia" = "SK", - "Slovenia" = "SI", - "Spain" = "ES", - "Sweden" = "SE", - "United Kingdom" = "UK", - "Bulgaria" = "BG", - "Croatia" = "HR")) %>% - select(NACE_R2,geo,Value) %>% - mutate(Value = parse_number(Value), - Value = as.numeric(Value)) %>% - spread(NACE_R2,Value) %>% - clean_names() %>% - mutate(HH_HEAT = heating_cooling_activities_by_households/total_activities_by_households, - HH_TRA = transport_activities_by_households/total_activities_by_households, - HH_OTH = other_activities_by_households/total_activities_by_households) %>% - select(geo,HH_HEAT,HH_TRA,HH_OTH) - - -env_ac_pefasu_TR = env_ac_pefasu_no_TR %>% - filter(geo == "BG") %>% - mutate(geo = dplyr::recode(geo, - "BG" = "TR")) - -env_ac_pefasu = rbind(env_ac_pefasu_no_TR,env_ac_pefasu_TR) %>% - gather(sector,share_of_total_energy,-geo) - -env_ac_ainah_r2 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/env_ac_ainah_r2_1_Data.csv")) %>% - filter(TIME == 2015) %>% - mutate(geo = dplyr::recode(GEO,"Austria" = "AT", - "Belgium" = "BE", - "Cyprus" = "CY", - "Czechia" = "CZ", - "Denmark" = "DK", - "Estonia" = "EE", - "Finland" = "FI", - "France" = "FR", - "Germany (until 1990 former territory of the FRG)" = "DE", - "Greece" = "EL", - "Hungary" = "HU", - "Ireland" = "IE", - "Italy" = "IT", - "Latvia" = "LV", - "Lithuania" = "LT", - "Luxembourg" = "LU", - "Malta" = "MT", - "Netherlands" = "NL", - "Norway" = "NO", - "Poland" = "PL", - "Portugal" = "PT", - "Romania" = "RO", - "Slovakia" = "SK", - "Slovenia" = "SI", - "Spain" = "ES", - "Sweden" = "SE", - "Turkey" = "TR", - "United Kingdom" = "UK", - "Bulgaria" = "BG", - "Croatia" = "HR")) %>% - select(NACE_R2,AIRPOL,geo,Value) %>% - mutate(Value = parse_number(Value), - Value = as.numeric(Value)) %>% - spread(NACE_R2,Value) %>% - clean_names() %>% - mutate(HH_HEAT = heating_cooling_activities_by_households/total_activities_by_households, - HH_TRA = transport_activities_by_households/total_activities_by_households, - HH_OTH = other_activities_by_households/total_activities_by_households) %>% - select(geo,airpol,HH_HEAT,HH_TRA,HH_OTH) - - -env_ac_ainah_r2_co2 = env_ac_ainah_r2 %>% - filter(airpol == "Carbon dioxide") %>% - select(-airpol) %>% - gather(sector,share_of_total_co2,-geo) - -env_ac_ainah_r2_ch4 = env_ac_ainah_r2 %>% - filter(airpol == "Methane") %>% - select(-airpol) %>% - gather(sector,share_of_total_ch4,-geo) - -env_ac_ainah_r2_n2o = env_ac_ainah_r2 %>% - filter(airpol == "Nitrous oxide") %>% - select(-airpol) %>% - gather(sector,share_of_total_n2o,-geo) - -direct_FD_fp_long = national_fp %>% - filter(fd_category == "Final consumption expenditure by households", - geo %in% c("AT", - "BE", "BG", "CY", "CZ", - "DE" , "DK" , "EE" , - "ES" , "FI" , "FR" , - "UK", "EL", "HR" , - "HU" , "IE" , "IT" , - "LT" , "LU" , "LV" , - "MT" , "NL" , "PL" , - "PT" , "TR" , "SK" , - "SI" , "SE" , "RO" , - "NO")) %>% - select(year,geo,fd_category,direct_FD_co2, - direct_FD_co2_noncombustion_cement, - direct_FD_co2_noncombustion_lime, - direct_FD_co2_agriculture_peatdecay, - direct_FD_co2_waste_biogenic, - direct_FD_co2_waste_fossil, - direct_FD_ch4, - direct_FD_ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_oilrefinery, - direct_FD_ch4_agriculture, - direct_FD_ch4_waste, - direct_FD_n2o, - direct_FD_n2o_agriculture, - direct_FD_sf6, - direct_FD_hfc, - direct_FD_pfc, - direct_FD_energy, - direct_FD_biomass, - direct_FD_const_materials, - direct_FD_ffuels, - direct_FD_ores, - direct_FD_cropland, - direct_FD_forest_land, - direct_FD_pasture_land) %>% - slice(rep(1:n(), each = 3)) - -sector = rep(c("HH_HEAT","HH_TRA","HH_OTH"), nrow(direct_FD_fp_long)/3) - -direct_FD_fp_long_disagg = cbind(sector,direct_FD_fp_long) %>% - mutate(coicop = ifelse(sector == "HH_TRA","CP072", - ifelse(sector == "HH_HEAT","CP045","CP05")), - five_sectors = ifelse(sector == "HH_TRA", "transport", - ifelse(sector == "HH_HEAT", "shelter", "manufactured goods"))) %>% - left_join(env_ac_ainah_r2_co2, by = c("geo","sector")) %>% - left_join(env_ac_ainah_r2_ch4, by = c("geo","sector")) %>% - left_join(env_ac_ainah_r2_n2o, by = c("geo","sector")) %>% - left_join(env_ac_pefasu, by = c("geo","sector")) %>% - mutate(direct_FD_co2 = (direct_FD_co2 + - direct_FD_co2_noncombustion_cement + - direct_FD_co2_noncombustion_lime + - direct_FD_co2_agriculture_peatdecay + - direct_FD_co2_waste_biogenic + - direct_FD_co2_waste_fossil)*share_of_total_co2, - direct_FD_ch4 = (direct_FD_ch4 + - direct_FD_ch4_noncombustion_gas + - direct_FD_ch4_noncombustion_oil + - direct_FD_ch4_noncombustion_anthracite + - direct_FD_ch4_noncombustion_bituminouscoal + - direct_FD_ch4_noncombustion_cokingcoal + - direct_FD_ch4_noncombustion_lignite + - direct_FD_ch4_noncombustion_subbituminouscoal + - direct_FD_ch4_noncombustion_oilrefinery + - direct_FD_ch4_agriculture + - direct_FD_ch4_waste)*share_of_total_ch4, - direct_FD_n2o = (direct_FD_n2o + - direct_FD_n2o_agriculture)*share_of_total_n2o, - direct_FD_energy = direct_FD_energy*share_of_total_energy) %>% - left_join(shares, by = c("year","geo","coicop")) %>% - mutate(disaggregated_direct_FD_co2 = direct_FD_co2*share, - disaggregated_direct_FD_ch4 = direct_FD_ch4*share, - disaggregated_direct_FD_n2o = direct_FD_n2o*share, - disaggregated_direct_FD_energy = direct_FD_energy*share) %>% - select(year,geo,sector, quintile, - coicop, five_sectors, - disaggregated_direct_FD_co2, - disaggregated_direct_FD_ch4, - disaggregated_direct_FD_n2o, - disaggregated_direct_FD_energy) - -direct_FD_co2 = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_co2) %>% - spread(quintile,disaggregated_direct_FD_co2) %>% - rename(q1_co2 = QUINTILE1, - q2_co2 = QUINTILE2, - q3_co2 = QUINTILE3, - q4_co2 = QUINTILE4, - q5_co2 = QUINTILE5) %>% - mutate(q1_co2_domestic = q1_co2, - q2_co2_domestic = q2_co2, - q3_co2_domestic = q3_co2, - q4_co2_domestic = q4_co2, - q5_co2_domestic = q5_co2, - co2_total = q1_co2+q2_co2+q3_co2+q4_co2+q5_co2, - co2_total_domestic = q1_co2_domestic+ - q2_co2_domestic+q3_co2_domestic+ - q4_co2_domestic+q5_co2_domestic) - -direct_FD_ch4 = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_ch4) %>% - spread(quintile,disaggregated_direct_FD_ch4) %>% - rename(q1_ch4 = QUINTILE1, - q2_ch4 = QUINTILE2, - q3_ch4 = QUINTILE3, - q4_ch4 = QUINTILE4, - q5_ch4 = QUINTILE5) %>% - mutate(q1_ch4_domestic = q1_ch4, - q2_ch4_domestic = q2_ch4, - q3_ch4_domestic = q3_ch4, - q4_ch4_domestic = q4_ch4, - q5_ch4_domestic = q5_ch4, - ch4_total = q1_ch4+q2_ch4+q3_ch4+q4_ch4+q5_ch4, - ch4_total_domestic = q1_ch4_domestic+ - q2_ch4_domestic+q3_ch4_domestic+ - q4_ch4_domestic+q5_ch4_domestic) - - -direct_FD_n2o = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_n2o) %>% - spread(quintile,disaggregated_direct_FD_n2o) %>% - rename(q1_n2o = QUINTILE1, - q2_n2o = QUINTILE2, - q3_n2o = QUINTILE3, - q4_n2o = QUINTILE4, - q5_n2o = QUINTILE5) %>% - mutate(q1_n2o_domestic = q1_n2o, - q2_n2o_domestic = q2_n2o, - q3_n2o_domestic = q3_n2o, - q4_n2o_domestic = q4_n2o, - q5_n2o_domestic = q5_n2o, - n2o_total = q1_n2o+q2_n2o+q3_n2o+q4_n2o+q5_n2o, - n2o_total_domestic = q1_n2o_domestic+ - q2_n2o_domestic+q3_n2o_domestic+ - q4_n2o_domestic+q5_n2o_domestic) - -direct_FD_energy = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_energy) %>% - spread(quintile,disaggregated_direct_FD_energy) %>% - rename(q1_energy = QUINTILE1, - q2_energy = QUINTILE2, - q3_energy = QUINTILE3, - q4_energy = QUINTILE4, - q5_energy = QUINTILE5) %>% - mutate(q1_energy_domestic = q1_energy, - q2_energy_domestic = q2_energy, - q3_energy_domestic = q3_energy, - q4_energy_domestic = q4_energy, - q5_energy_domestic = q5_energy, - energy_total = q1_energy+q2_energy+q3_energy+q4_energy+q5_energy, - energy_total_domestic = q1_energy_domestic+ - q2_energy_domestic+q3_energy_domestic+ - q4_energy_domestic+q5_energy_domestic) - - -direct_FD_fp_wide = direct_FD_co2 %>% - left_join(direct_FD_ch4, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - left_join(direct_FD_n2o, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - left_join(direct_FD_energy, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - mutate(country_of_production = geo) %>% - mutate(q1_co2eq = q1_co2 + q1_ch4 + q1_n2o, - q2_co2eq = q2_co2 + q2_ch4 + q2_n2o, - q3_co2eq = q3_co2 + q3_ch4 + q3_n2o, - q4_co2eq = q4_co2 + q4_ch4 + q4_n2o, - q5_co2eq = q5_co2 + q5_ch4 + q5_n2o, - co2eq_total = q1_co2eq + - q2_co2eq + q3_co2eq + - q4_co2eq + q5_co2eq, - q1_co2eq_domestic = q1_co2_domestic + q1_ch4_domestic + q1_n2o_domestic, - q2_co2eq_domestic = q2_co2_domestic + q2_ch4_domestic + q2_n2o_domestic, - q3_co2eq_domestic = q3_co2_domestic + q3_ch4_domestic + q3_n2o_domestic, - q4_co2eq_domestic = q4_co2_domestic + q4_ch4_domestic + q4_n2o_domestic, - q5_co2eq_domestic = q5_co2_domestic + q5_ch4_domestic + q5_n2o_domestic, - co2eq_total_domestic = q1_co2eq_domestic + - q2_co2eq_domestic + q3_co2eq_domestic + - q4_co2eq_domestic + q5_co2eq_domestic) %>% - select(-q1_ch4, - -q2_ch4, - -q3_ch4, - -q4_ch4, - -q5_ch4, - -ch4_total, - -q1_ch4_domestic, - -q2_ch4_domestic, - -q3_ch4_domestic, - -q4_ch4_domestic, - -q5_ch4_domestic, - -ch4_total_domestic, - -q1_n2o, - -q2_n2o, - -q3_n2o, - -q4_n2o, - -q5_n2o, - -n2o_total, - -q1_n2o_domestic, - -q2_n2o_domestic, - -q3_n2o_domestic, - -q4_n2o_domestic, - -q5_n2o_domestic, - -n2o_total_domestic) - - - -results = fd_exiobase %>% - left_join(TIVs, by = c("year", "country_of_production", "coicop", "sector")) %>% - left_join(europe_TIVs, by = c("year", "country_of_production", "coicop", "sector", "five_sectors")) %>% - left_join(domestic_TIVs, by = c("year", "geo", "country_of_production", "coicop", "sector", "five_sectors")) %>% - transmute(year,geo,country_of_production,sector,coicop,five_sectors, - QUINTILE1, - QUINTILE2, - QUINTILE3, - QUINTILE4, - QUINTILE5, - fd_total = QUINTILE1+QUINTILE2+QUINTILE3+QUINTILE4+QUINTILE5, - TIV_CO2 = TIV_CO2 + - TIV_CO2_noncombustion_cement + - TIV_CO2_noncombustion_lime + - TIV_CO2_agriculture_peatdecay + - TIV_CO2_waste_biogenic + - TIV_CO2_waste_fossil, - q1_co2 = QUINTILE1*TIV_CO2, - q2_co2 = QUINTILE2*TIV_CO2, - q3_co2 = QUINTILE3*TIV_CO2, - q4_co2 = QUINTILE4*TIV_CO2, - q5_co2 = QUINTILE5*TIV_CO2, - co2_total = q1_co2+q2_co2+q3_co2+q4_co2+q5_co2, - TIV_CO2_domestic = TIV_CO2_domestic + - TIV_CO2_noncombustion_cement_domestic + - TIV_CO2_noncombustion_lime_domestic + - TIV_CO2_agriculture_peatdecay_domestic + - TIV_CO2_waste_biogenic_domestic + - TIV_CO2_waste_fossil_domestic, - q1_co2_domestic = QUINTILE1*TIV_CO2_domestic, - q2_co2_domestic = QUINTILE2*TIV_CO2_domestic, - q3_co2_domestic = QUINTILE3*TIV_CO2_domestic, - q4_co2_domestic = QUINTILE4*TIV_CO2_domestic, - q5_co2_domestic = QUINTILE5*TIV_CO2_domestic, - co2_total_domestic = q1_co2_domestic+q2_co2_domestic+q3_co2_domestic+q4_co2_domestic+q5_co2_domestic, - TIV_CO2_europe = TIV_CO2_europe + - TIV_CO2_noncombustion_cement_europe + - TIV_CO2_noncombustion_lime_europe + - TIV_CO2_agriculture_peatdecay_europe + - TIV_CO2_waste_biogenic_europe + - TIV_CO2_waste_fossil_europe, - q1_co2_europe = QUINTILE1*(TIV_CO2_europe - TIV_CO2_domestic), - q2_co2_europe = QUINTILE2*(TIV_CO2_europe - TIV_CO2_domestic), - q3_co2_europe = QUINTILE3*(TIV_CO2_europe - TIV_CO2_domestic), - q4_co2_europe = QUINTILE4*(TIV_CO2_europe - TIV_CO2_domestic), - q5_co2_europe = QUINTILE5*(TIV_CO2_europe - TIV_CO2_domestic), - co2_total_europe = q1_co2_europe+q2_co2_europe+q3_co2_europe+q4_co2_europe+q5_co2_europe, - TIV_CO2eq = TIV_CO2 + - TIV_CH4 + - TIV_CH4_noncombustion_gas + - TIV_CH4_noncombustion_oil + - TIV_CH4_noncombustion_anthracite + - TIV_CH4_noncombustion_bituminouscoal + - TIV_CH4_noncombustion_cokingcoal + - TIV_CH4_noncombustion_lignite + - TIV_CH4_noncombustion_subbituminouscoal + - TIV_CH4_noncombustion_oilrefinery + - TIV_CH4_agriculture + - TIV_CH4_waste + - TIV_N2O + - TIV_N2O_agriculture + - TIV_SF6 + TIV_HFC + TIV_PFC, - q1_co2eq = QUINTILE1*TIV_CO2eq, - q2_co2eq = QUINTILE2*TIV_CO2eq, - q3_co2eq = QUINTILE3*TIV_CO2eq, - q4_co2eq = QUINTILE4*TIV_CO2eq, - q5_co2eq = QUINTILE5*TIV_CO2eq, - co2eq_total = q1_co2eq + q2_co2eq + q3_co2eq + q4_co2eq + q5_co2eq, - TIV_CO2eq_domestic = TIV_CO2_domestic + - TIV_CH4_domestic + - TIV_CH4_noncombustion_gas_domestic + - TIV_CH4_noncombustion_oil_domestic + - TIV_CH4_noncombustion_anthracite_domestic + - TIV_CH4_noncombustion_bituminouscoal_domestic + - TIV_CH4_noncombustion_cokingcoal_domestic + - TIV_CH4_noncombustion_lignite_domestic + - TIV_CH4_noncombustion_subbituminouscoal_domestic + - TIV_CH4_noncombustion_oilrefinery_domestic + - TIV_CH4_agriculture_domestic + - TIV_CH4_waste_domestic + - TIV_N2O_domestic + - TIV_N2O_agriculture_domestic + - TIV_SF6_domestic + TIV_HFC_domestic + TIV_PFC_domestic, - q1_co2eq_domestic = QUINTILE1*TIV_CO2eq_domestic, - q2_co2eq_domestic = QUINTILE2*TIV_CO2eq_domestic, - q3_co2eq_domestic = QUINTILE3*TIV_CO2eq_domestic, - q4_co2eq_domestic = QUINTILE4*TIV_CO2eq_domestic, - q5_co2eq_domestic = QUINTILE5*TIV_CO2eq_domestic, - co2eq_total_domestic = q1_co2eq_domestic + q2_co2eq_domestic + q3_co2eq_domestic + q4_co2eq_domestic + q5_co2eq_domestic, - TIV_CO2eq_europe = TIV_CO2_europe + - TIV_CH4_europe + - TIV_CH4_noncombustion_gas_europe + - TIV_CH4_noncombustion_oil_europe + - TIV_CH4_noncombustion_anthracite_europe + - TIV_CH4_noncombustion_bituminouscoal_europe + - TIV_CH4_noncombustion_cokingcoal_europe + - TIV_CH4_noncombustion_lignite_europe + - TIV_CH4_noncombustion_subbituminouscoal_europe + - TIV_CH4_noncombustion_oilrefinery_europe + - TIV_CH4_agriculture_europe + - TIV_CH4_waste_europe + - TIV_N2O_europe + - TIV_N2O_agriculture_europe + - TIV_SF6_europe + TIV_HFC_europe + TIV_PFC_europe, - q1_co2eq_europe = QUINTILE1*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q2_co2eq_europe = QUINTILE2*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q3_co2eq_europe = QUINTILE3*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q4_co2eq_europe = QUINTILE4*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - q5_co2eq_europe = QUINTILE5*(TIV_CO2eq_europe - TIV_CO2eq_domestic), - co2eq_total_europe = q1_co2eq_europe + q2_co2eq_europe + q3_co2eq_europe + q4_co2eq_europe + q5_co2eq_europe, - TIV_energy, - q1_energy = QUINTILE1*TIV_energy, - q2_energy = QUINTILE2*TIV_energy, - q3_energy = QUINTILE3*TIV_energy, - q4_energy = QUINTILE4*TIV_energy, - q5_energy = QUINTILE5*TIV_energy, - energy_total = q1_energy+q2_energy+q3_energy+q4_energy+q5_energy, - TIV_energy_domestic, - q1_energy_domestic = QUINTILE1*TIV_energy_domestic, - q2_energy_domestic = QUINTILE2*TIV_energy_domestic, - q3_energy_domestic = QUINTILE3*TIV_energy_domestic, - q4_energy_domestic = QUINTILE4*TIV_energy_domestic, - q5_energy_domestic = QUINTILE5*TIV_energy_domestic, - energy_total_domestic = q1_energy_domestic+q2_energy_domestic+q3_energy_domestic+q4_energy_domestic+q5_energy_domestic, - TIV_energy_europe, - q1_energy_europe = QUINTILE1*(TIV_energy_europe - TIV_energy_domestic), - q2_energy_europe = QUINTILE2*(TIV_energy_europe - TIV_energy_domestic), - q3_energy_europe = QUINTILE3*(TIV_energy_europe - TIV_energy_domestic), - q4_energy_europe = QUINTILE4*(TIV_energy_europe - TIV_energy_domestic), - q5_energy_europe = QUINTILE5*(TIV_energy_europe - TIV_energy_domestic), - energy_total_europe = q1_energy_europe+q2_energy_europe+q3_energy_europe+q4_energy_europe+q5_energy_europe, - TIV_materials = TIV_biomass+TIV_const_materials+TIV_ffuels+TIV_ores, - q1_materials = QUINTILE1*TIV_materials, - q2_materials = QUINTILE2*TIV_materials, - q3_materials = QUINTILE3*TIV_materials, - q4_materials = QUINTILE4*TIV_materials, - q5_materials = QUINTILE5*TIV_materials, - materials_total = q1_materials+q2_materials+q3_materials+q4_materials+q5_materials, - TIV_materials_domestic = TIV_biomass_domestic+TIV_const_materials_domestic+TIV_ffuels_domestic+TIV_ores_domestic, - q1_materials_domestic = QUINTILE1*TIV_materials_domestic, - q2_materials_domestic = QUINTILE2*TIV_materials_domestic, - q3_materials_domestic = QUINTILE3*TIV_materials_domestic, - q4_materials_domestic = QUINTILE4*TIV_materials_domestic, - q5_materials_domestic = QUINTILE5*TIV_materials_domestic, - materials_total_domestic = q1_materials_domestic+q2_materials_domestic+q3_materials_domestic+q4_materials_domestic+q5_materials_domestic, - TIV_materials_europe = TIV_biomass_europe+TIV_const_materials_europe+TIV_ffuels_europe+TIV_ores_europe, - q1_materials_europe = QUINTILE1*(TIV_materials_europe - TIV_materials_domestic), - q2_materials_europe = QUINTILE2*(TIV_materials_europe - TIV_materials_domestic), - q3_materials_europe = QUINTILE3*(TIV_materials_europe - TIV_materials_domestic), - q4_materials_europe = QUINTILE4*(TIV_materials_europe - TIV_materials_domestic), - q5_materials_europe = QUINTILE5*(TIV_materials_europe - TIV_materials_domestic), - materials_total_europe = q1_materials_europe+q2_materials_europe+q3_materials_europe+q4_materials_europe+q5_materials_europe, - TIV_land_use = TIV_cropland+TIV_forest_land+TIV_pasture_land, - q1_land_use = QUINTILE1*TIV_land_use, - q2_land_use = QUINTILE2*TIV_land_use, - q3_land_use = QUINTILE3*TIV_land_use, - q4_land_use = QUINTILE4*TIV_land_use, - q5_land_use = QUINTILE5*TIV_land_use, - land_use_total =q1_land_use+q2_land_use+q3_land_use+q4_land_use+q5_land_use, - TIV_land_use_domestic = TIV_cropland_domestic+TIV_forest_land_domestic+TIV_pasture_land_domestic, - q1_land_use_domestic = QUINTILE1*TIV_land_use_domestic, - q2_land_use_domestic = QUINTILE2*TIV_land_use_domestic, - q3_land_use_domestic = QUINTILE3*TIV_land_use_domestic, - q4_land_use_domestic = QUINTILE4*TIV_land_use_domestic, - q5_land_use_domestic = QUINTILE5*TIV_land_use_domestic, - land_use_total_domestic =q1_land_use_domestic+q2_land_use_domestic+q3_land_use_domestic+q4_land_use_domestic+q5_land_use_domestic, - TIV_land_use_europe = TIV_cropland_europe+TIV_forest_land_europe+TIV_pasture_land_europe, - q1_land_use_europe = QUINTILE1*(TIV_land_use_europe - TIV_land_use_domestic), - q2_land_use_europe = QUINTILE2*(TIV_land_use_europe - TIV_land_use_domestic), - q3_land_use_europe = QUINTILE3*(TIV_land_use_europe - TIV_land_use_domestic), - q4_land_use_europe = QUINTILE4*(TIV_land_use_europe - TIV_land_use_domestic), - q5_land_use_europe = QUINTILE5*(TIV_land_use_europe - TIV_land_use_domestic), - land_use_total_europe =q1_land_use_europe+q2_land_use_europe+q3_land_use_europe+q4_land_use_europe+q5_land_use_europe) - -results_with_direct_FD_fp = bind_rows(results,direct_FD_fp_wide) -#write.csv(results, paste0(data_dir_income_stratified_footprints, "/results_no_rent_ixi.csv")) - - -### create compressed results_ixi rds file - -#if (!require("pacman")) install.packages("pacman") -#pacman::p_load(tidyverse, -# janitor, -# here) - -#dat_all = read_csv(here("data/results_ixi.csv")) %>% -# clean_names() - -dat_all = results_with_direct_FD_fp %>% - clean_names() - -# convert sector labels to IDs -sectors = dat_all %>% - distinct(sector) %>% - mutate(sector_id = row_number()) - -#write_csv(sectors, here("data/sector_labels.csv")) -write_csv(sectors, paste0(data_dir_income_stratified_footprints, "/sectors_method1_pxp_pps_hh.csv")) - -# convert aggregated sector labels to IDs -sectors_agg = dat_all %>% - distinct(five_sectors) %>% - mutate(sector_agg_id = row_number()) - -#write_csv(sectors_agg, here("data/sector_agg_labels.csv")) -write_csv(sectors_agg, paste0(data_dir_income_stratified_footprints, "/sectors_agg_method1_pxp_pps_hh.csv")) - -# convert COICOP labels to IDs -coicop = dat_all %>% - distinct(coicop) %>% - mutate(coicop_id = row_number()) - -#write_csv(sectors_agg, here("data/sector_agg_labels.csv")) -write_csv(coicop, paste0(data_dir_income_stratified_footprints, "/coicop_method1_pxp_pps_hh.csv")) - -# replace sector text labels with numerical IDs (save space) -dat_compressed = dat_all %>% - left_join(sectors, by="sector") %>% - left_join(sectors_agg, by="five_sectors") %>% - left_join(coicop, by = "coicop") %>% - select(-c(sector, five_sectors,coicop)) - -# extract sector aggregation -sector_mapping = dat_compressed %>% - group_by(sector_id) %>% - summarise(sector_agg_id = first(sector_agg_id), - coicop_id = first(coicop_id)) - -# collapse country of origin -dat_results = dat_compressed %>% - select(-sector_agg_id,-coicop_id) %>% - group_by(year, geo, sector_id) %>% - summarise_if(is.numeric, sum, na.rm = TRUE) - -## extract final demand and pivot long -cols_final_demand = c("quintile1", "quintile2", "quintile3", "quintile4", "quintile5") -tmp_fd = dat_results %>% - select(year, geo, sector_id, cols_final_demand) %>% - pivot_longer(cols = cols_final_demand, - names_to = "quintile", - values_to = "fd_me") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 and pivot long -cols_co2 = c("q1_co2", "q2_co2", "q3_co2", "q4_co2", "q5_co2") -tmp_co2 = dat_results %>% - select(year, geo, sector_id, cols_co2) %>% - pivot_longer(cols = cols_co2, - names_to = "quintile", - values_to = "co2_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 domestic and pivot long -cols_co2_domestic = c("q1_co2_domestic", "q2_co2_domestic", "q3_co2_domestic", "q4_co2_domestic", "q5_co2_domestic") -tmp_co2_domestic = dat_results %>% - select(year, geo, sector_id, cols_co2_domestic) %>% - pivot_longer(cols = cols_co2_domestic, - names_to = "quintile", - values_to = "co2_domestic_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 europe and pivot long -cols_co2_europe = c("q1_co2_europe", "q2_co2_europe", "q3_co2_europe", "q4_co2_europe", "q5_co2_europe") -tmp_co2_europe = dat_results %>% - select(year, geo, sector_id, cols_co2_europe) %>% - pivot_longer(cols = cols_co2_europe, - names_to = "quintile", - values_to = "co2_europe_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - - -## extract co2eq and pivot long -cols_co2eq = c("q1_co2eq", "q2_co2eq", "q3_co2eq", "q4_co2eq", "q5_co2eq") -tmp_co2eq = dat_results %>% - select(year, geo, sector_id, cols_co2eq) %>% - pivot_longer(cols = cols_co2eq, - names_to = "quintile", - values_to = "co2eq_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2eq domestic and pivot long -cols_co2eq_domestic = c("q1_co2eq_domestic", "q2_co2eq_domestic", "q3_co2eq_domestic", "q4_co2eq_domestic", "q5_co2eq_domestic") -tmp_co2eq_domestic = dat_results %>% - select(year, geo, sector_id, cols_co2eq_domestic) %>% - pivot_longer(cols = cols_co2eq_domestic, - names_to = "quintile", - values_to = "co2eq_domestic_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2eq europe and pivot long -cols_co2eq_europe = c("q1_co2eq_europe", "q2_co2eq_europe", "q3_co2eq_europe", "q4_co2eq_europe", "q5_co2eq_europe") -tmp_co2eq_europe = dat_results %>% - select(year, geo, sector_id, cols_co2eq_europe) %>% - pivot_longer(cols = cols_co2eq_europe, - names_to = "quintile", - values_to = "co2eq_europe_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy use and pivot long -cols_energy = c("q1_energy","q2_energy","q3_energy","q4_energy","q5_energy") -tmp_energy = dat_results %>% - select(year, geo, sector_id, cols_energy) %>% - pivot_longer(cols = cols_energy, - names_to = "quintile", - values_to = "energy_use_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy domestic and pivot long -cols_energy_domestic = c("q1_energy_domestic","q2_energy_domestic","q3_energy_domestic","q4_energy_domestic","q5_energy_domestic") -tmp_energy_domestic = dat_results %>% - select(year, geo, sector_id, cols_energy_domestic) %>% - pivot_longer(cols = cols_energy_domestic, - names_to = "quintile", - values_to = "energy_use_domestic_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy europe and pivot long -cols_energy_europe = c("q1_energy_europe","q2_energy_europe","q3_energy_europe","q4_energy_europe","q5_energy_europe") -tmp_energy_europe = dat_results %>% - select(year, geo, sector_id, cols_energy_europe) %>% - pivot_longer(cols = cols_energy_europe, - names_to = "quintile", - values_to = "energy_use_europe_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -### TODO: also convert to other indicators to this format (as blocks above) -### TODO: left join all indicators back to "results_formated" like her with co2 -results_recombined = tmp_fd %>% - left_join(tmp_co2, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2_domestic, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2_europe, by = c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2eq, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2eq_domestic, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_co2eq_europe, by = c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_energy, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_energy_domestic, by=c("year", "geo", "sector_id", "quint")) %>% - left_join(tmp_energy_europe, by = c("year", "geo", "sector_id", "quint")) - - - -# finally re-join aggregated sector IDs -results_formatted = results_recombined %>% - left_join(sector_mapping, by="sector_id") %>% - ungroup() %>% - select(-coicop_id) - -#write_rds(results_formated, here("/results_formated.rds")) - -write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_pxp_pps_hh_no_rent.csv")) - -#write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_pxp_pps_hh_no_rent.rds")) - - -#write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_pxp_pps_ae.csv")) -#write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, "/results_formatted_method1_pxp_pps_ae.rds")) - - - - - - - -################################################### !!!! method 2 !!!! - IXI version - PPS HH - RENT NOT MAPPED TO EXIOBASE !!!!! ############################# -############################################################################################################################################################### -############################################################################################################################################################### - - -# 'results' data frame the second way - -# aggregate - playing around trying to go the other way - -# load 'mean expenditure by quintile' data -hbs_exp_t133 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/hbs_exp_t133.csv")) -# rename and arrange by country -mean_expenditure_by_quintile = hbs_exp_t133 %>% - rename(geo = 3, quintile = "quantile") %>% - arrange(geo) - -# load 'mean expenditure by quintile and coicop' data -hbs_str_t223 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/hbs_str_t223.csv")) -# rename and arrange by country -mean_expenditure_by_coicop_sector = hbs_str_t223 %>% - rename(geo = 4, quintile = "quantile") %>% - arrange(geo) - -# create long data sets for both - -mean_expenditure_by_quintile_long = mean_expenditure_by_quintile %>% - filter(unit == "PPS_HH") %>% - filter(!(quintile %in% c("UNK","TOTAL"))) %>% - select(-unit) %>% - gather(year,euro_pps,-quintile,-geo) - -mean_expenditure_by_coicop_sector_long = mean_expenditure_by_coicop_sector %>% - filter(!(quintile %in% c("UNK","TOTAL"))) %>% - select(-unit) %>% - gather(year,pm,-quintile,-coicop,-geo) %>% - mutate(coicop = dplyr::recode(coicop, "CP041" = "rent", - "CP042" = "rent")) %>% - group_by(geo,quintile,coicop,year) %>% - mutate(pm = parse_number(pm), - pm = as.numeric(pm)) %>% - summarise(pm = sum(pm, na.rm = TRUE)) %>% - ungroup() %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE1" & - coicop == "CP072", 92-21-14,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE2" & - coicop == "CP072", 108-22-12,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE3" & - coicop == "CP072", 124-32-11,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE4" & - coicop == "CP072", 133-43-10,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2005 & quintile == "QUINTILE5" & - coicop == "CP072", 162-81-11,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE1" & - coicop == "CP044", 412-4-78-322,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE2" & - coicop == "CP044", 355-5-68-265,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE3" & - coicop == "CP044", 325-8-64-229,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE4" & - coicop == "CP044", 300-9-58-204,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2010 & quintile == "QUINTILE5" & - coicop == "CP044", 249-10-46-167,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE1" & - coicop == "CP044", 433-3-82-340,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE2" & - coicop == "CP044", 376-6-70-284,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE3" & - coicop == "CP044", 351-9-67-251,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE4" & - coicop == "CP044", 326-10-61-228,pm)) %>% - mutate(pm = ifelse(geo == "DE" & year == 2015 & quintile == "QUINTILE5" & - coicop == "CP044", 280-9-49-195,pm)) - -join_expenditures = mean_expenditure_by_coicop_sector_long %>% - left_join(mean_expenditure_by_quintile_long, by = c("geo","quintile","year")) %>% - mutate(euro_pps = as.numeric(euro_pps), - pm = as.numeric(pm), - euro_pps_coicop = pm*(euro_pps/1000)) - - -# load margin tables - -trade_and_transport = read.csv(paste0(data_dir_income_stratified_footprints, "/data/SNA_TABLE45_20042020103737298.csv")) %>% - select(LOCATION, PRODUCT, Product, Year, Value) %>% - mutate(geo = dplyr::recode(LOCATION,"AUT" = "AT", - "BEL" = "BE", - "CYP" = "CY", - "CZE" = "CZ", - "DNK" = "DK", - "EST" = "EE", - "FIN" = "FI", - "FRA" = "FR", - "DEU" = "DE", - "GRC" = "EL", - "HUN" = "HU", - "IRL" = "IE", - "ITA" = "IT", - "LVA" = "LV", - "LTU" = "LT", - "LUX" = "LU", - "MLT" = "MT", - "MNE" = "ME", - "NLD" = "NL", - "NOR" = "NO", - "POL" = "PL", - "PRT" = "PT", - "ROU" = "RO", - "SRB" = "RS", - "SVK" = "SK", - "SVN" = "SI", - "ESP" = "ES", - "SWE" = "SE", - "CHE" = "CH", - "MKD" = "MK", - "TUR" = "TR", - "GBR" = "UK", - "BGR" = "BG", - "HRV" = "HR")) %>% - select(geo, Year, PRODUCT, Value) %>% - rename(year = Year, - trade_and_transport = Value) %>% - mutate(trade_and_transport = trade_and_transport/100) %>% - rename(geo_join = geo) - - - -taxes_less_subsidies = read.csv(paste0(data_dir_income_stratified_footprints, "/data/SNA_TABLE45_20042020104120395.csv")) %>% - select(LOCATION, PRODUCT, Product, Year, Value) %>% - mutate(geo = dplyr::recode(LOCATION,"AUT" = "AT", - "BEL" = "BE", - "CYP" = "CY", - "CZE" = "CZ", - "DNK" = "DK", - "EST" = "EE", - "FIN" = "FI", - "FRA" = "FR", - "DEU" = "DE", - "GRC" = "EL", - "HUN" = "HU", - "IRL" = "IE", - "ITA" = "IT", - "LVA" = "LV", - "LTU" = "LT", - "LUX" = "LU", - "MLT" = "MT", - "MNE" = "ME", - "NLD" = "NL", - "NOR" = "NO", - "POL" = "PL", - "PRT" = "PT", - "ROU" = "RO", - "SRB" = "RS", - "SVK" = "SK", - "SVN" = "SI", - "ESP" = "ES", - "SWE" = "SE", - "CHE" = "CH", - "MKD" = "MK", - "TUR" = "TR", - "GBR" = "UK", - "BGR" = "BG", - "HRV" = "HR")) %>% - select(geo, Year, PRODUCT, Value) %>% - rename(year = Year, - taxes_less_subsidies = Value) %>% - mutate(taxes_less_subsidies = taxes_less_subsidies/100) %>% - rename(geo_join = geo) - -# create margins dataframe - -geo_real = rep(c("AT", - "BE", - "CY", - "CZ", - "DK", - "EE", - "FI", - "FR", - "DE", - "EL", - "HU", - "IE", - "IT", - "LV", - "LT", - "LU", - "MT", - "ME", - "NL", - "NO", - "PL", - "PT", - "RO", - "RS", - "SK", - "SI", - "ES", - "SE", - "MK", - "TR", - "UK", - "BG", - "HR"),each = 16) - -geo_join = rep(c("AT", - "BE", - "CY", - "CZ", - "DK", - "LV", - "FI", - "FR", - "AT", - "EL", - "HU", - "UK", - "IT", - "LV", - "LV", - "LU", - "MT", - "ME", - "NL", - "FI", - "PL", - "PT", - "RO", - "RS", - "SK", - "SI", - "PT", - "FI", - "MK", - "BG", - "UK", - "BG", - "HR"),each = 16) - -year = rep(2010,length(geo_real)) - -PRODUCT = c("P10_12", - "P13_15", - "P68A", - "PF", - "PE", - "PD", - "PC", - "PQ", - "P29", - "P19", - "P30", - "P61", - "PR", - "PP", - "PI", - "PS") - -margin_sectors = data.frame(geo_real,geo_join,year,PRODUCT) - -# join everything - and impute - -margins = margin_sectors %>% - left_join(taxes_less_subsidies, by = c("geo_join","year","PRODUCT")) %>% - left_join(trade_and_transport, by = c("geo_join","year","PRODUCT")) %>% - select(-geo_join) %>% - rename(geo = geo_real) %>% - mutate(taxes_less_subsidies = ifelse(geo == "CZ" & PRODUCT == "P68A", 0, taxes_less_subsidies)) %>% - mutate(trade_and_transport = ifelse(geo == "CZ" & PRODUCT == "P68A", 0, trade_and_transport)) %>% - mutate(taxes_less_subsidies = ifelse(geo == "SK" & PRODUCT == "P68A", 0, taxes_less_subsidies)) %>% - mutate(trade_and_transport = ifelse(geo == "SK" & PRODUCT == "P68A", 0, trade_and_transport)) %>% - select(-year) - - -# join margin data to join_expenditures - -with_margins = join_expenditures %>% - mutate(year = as.numeric(year), - PRODUCT = dplyr::recode(coicop, - "CP011" = "P10_12", - "CP012" = "P10_12", - "CP02" = "P10_12", - "CP03" = "P13_15", - "rent" = "P68A", - "CP043" = "PF", - "CP044" = "PE", - "CP045" = "PD", - "CP05" = "PC", - "CP06" = "PQ", - "CP071" = "P29", - "CP072" = "P19", - "CP073" = "P30", - "CP08" = "P61", - "CP09" = "PR", - "CP10" = "PP", - "CP11" = "PI", - "CP12" = "PS")) %>% - left_join(margins, by = c("geo","PRODUCT")) %>% - mutate(euro_pps_coicop_bp = euro_pps_coicop*(1 - (trade_and_transport + taxes_less_subsidies))) - - -# re-create expenditure - -mean_expenditure_by_quintile_long_bp = with_margins %>% - group_by(quintile,geo,year) %>% - summarise(euro_pps_bp = sum(euro_pps_coicop_bp, na.rm = TRUE)) - - -mean_expenditure_by_coicop_sector_long_bp = with_margins %>% - left_join(mean_expenditure_by_quintile_long_bp, by = c("quintile","geo","year")) %>% - mutate(pm_bp = (euro_pps_coicop_bp/euro_pps_bp)*1000) %>% - select(quintile,coicop,geo,year,pm_bp) - - -### - -shares = join_expenditures %>% - group_by(coicop,geo,year) %>% - mutate(share = euro_pps_coicop/sum(euro_pps_coicop)) - - -################################################### !!!! method 2 - IXI version - PPS HH NO RENT !!!! #################################################### -########################################################################################################################################################## -########################################################################################################################################################## - -# pre-processing - -data_dir_exiobase = paste("/",file.path("data","metab","Exiobase", fsep=.Platform$file.sep),sep="") - -# Exiobase - ixi version - -years_exb_ixi = c(2005,2010,2015) - - -Eurostat_countries_hh_fd = NULL - -total_fd = NULL - -TIVs = NULL - -domestic_TIVs = NULL - -europe_TIVs = NULL - -national_fp = NULL - -for (i in years_exb_ixi){ - year_current = i - - Exiobase_FD = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/FD_",year_current,"_ixi.csv"))[,-1] - - # select household final demand vectors for relevant countries - figure out how to soft code this - - - AT = Exiobase_FD[,1] - BE = Exiobase_FD[,8] - BG = Exiobase_FD[,15] - CY = Exiobase_FD[,22] - CZ = Exiobase_FD[,29] - DE = Exiobase_FD[,36] - DK = Exiobase_FD[,43] - EE = Exiobase_FD[,50] - EL = Exiobase_FD[,78] - ES = Exiobase_FD[,57] - FI = Exiobase_FD[,64] - FR = Exiobase_FD[,71] - HR = Exiobase_FD[,85] - HU = Exiobase_FD[,92] - IE = Exiobase_FD[,99] - IT = Exiobase_FD[,106] - LT = Exiobase_FD[,113] - LU = Exiobase_FD[,120] - LV = Exiobase_FD[,127] - MT = Exiobase_FD[,134] - NL = Exiobase_FD[,141] - NO = Exiobase_FD[,288] - PL = Exiobase_FD[,148] - PT = Exiobase_FD[,155] - RO = Exiobase_FD[,162] - SE = Exiobase_FD[,169] - SI = Exiobase_FD[,176] - SK = Exiobase_FD[,183] - TR = Exiobase_FD[,274] - UK = Exiobase_FD[,190] - - Eurostat_countries = cbind(AT,BE,BG,CY,CZ,DE,DK,EE,EL,ES,FI,FR,HR,HU,IE,IT,LT,LU,LV,MT,NL,NO,PL,PT,RO,SE,SI,SK,TR,UK) - - year = as.character(rep(year_current,nrow(Eurostat_countries))) - look_Eurostat_countries = cbind(year,Eurostat_countries) - - Eurostat_countries_hh_fd = rbind(Eurostat_countries_hh_fd,look_Eurostat_countries) - - - eurostat_countries_colsums = colSums(Eurostat_countries) - - geo = data.frame(c("AT","BE","BG","CY","CZ","DE","DK","EE","EL","ES","FI", - "FR","HR","HU","IE","IT","LT","LU","LV","MT","NL","NO", - "PL","PT","RO","SE","SI","SK","TR","UK")) %>% rename_at(1,~"geo") - - year = rep(year_current, 30) - - fds = cbind(geo,year,eurostat_countries_colsums) %>% slice(rep(1:n(), each = 5)) - - quintiles = data.frame(rep(c("QUINTILE1","QUINTILE2","QUINTILE3","QUINTILE4","QUINTILE5"),30)) %>% rename_at(1,~"quintile") - - total_fd_year_current = cbind(fds,quintiles) - - total_fd = rbind(total_fd, total_fd_year_current) - - # labels - - Exiobase_T_labels = read.csv(paste0(data_dir_income_stratified_footprints, "/data/Exiobase_T_labels_ixi_w_coicop_mapping_no_rent.csv")) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - # TIVs - - # CO2 - combustion - air - - Exiobase_TIV_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_combustion_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_combustion_air_", year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_domestic) - - Exiobase_TIV_europe_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_combustion_air_", year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_europe,TIV_CO2_not_europe) - - # CO2 - noncombustion - cement - air - - Exiobase_TIV_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_noncombustion_cement_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_noncombustion_cement_domestic) - - Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_noncombustion_cement_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_noncombustion_cement_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_noncombustion_cement_europe,TIV_CO2_noncombustion_cement_not_europe) - - # CO2 - noncombustion - lime - air - - Exiobase_TIV_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_noncombustion_lime_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_noncombustion_lime_domestic) - - Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_noncombustion_lime_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_noncombustion_lime_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_noncombustion_lime_europe,TIV_CO2_noncombustion_lime_not_europe) - - # CO2 - agriculture - peat decay - air - - Exiobase_TIV_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_agriculture_peatdecay_domestic) - - Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_agriculture_peatdecay_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_agriculture_peatdecay_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_agriculture_peatdecay_europe,TIV_CO2_agriculture_peatdecay_not_europe) - - # CO2 - waste - biogenic - air - - Exiobase_TIV_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_biogenic_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_biogenic_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_waste_biogenic_domestic) - - Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_biogenic_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_waste_biogenic_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_waste_biogenic_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_waste_biogenic_europe,TIV_CO2_waste_biogenic_not_europe) - - # CO2 - waste - fossil - air - - Exiobase_TIV_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_co2_waste_fossil_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CO2_waste_fossil_domestic) - - Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_co2_waste_fossil_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CO2_waste_fossil_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CO2_waste_fossil_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CO2_waste_fossil_europe,TIV_CO2_waste_fossil_not_europe) - - - # CH4 - combustion -air - - Exiobase_TIV_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_domestic) - - Exiobase_TIV_europe_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_europe,TIV_CH4_not_europe) - - # CH4 - noncombustion - gas - air - - Exiobase_TIV_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_gas_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_gas_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_gas_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_gas_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_gas_europe,TIV_CH4_noncombustion_gas_not_europe) - - # CH4 - noncombustion - oil - air - - Exiobase_TIV_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_oil_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_oil_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_oil_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_oil_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_oil_europe,TIV_CH4_noncombustion_oil_not_europe) - - # CH4 - noncombustion - anthracite - air - - Exiobase_TIV_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_anthracite_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_anthracite_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_anthracite_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_anthracite_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_anthracite_europe,TIV_CH4_noncombustion_anthracite_not_europe) - - # CH4 - noncombustion - bituminouscoal - air - - Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_bituminouscoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_bituminouscoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_bituminouscoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_bituminouscoal_europe,TIV_CH4_noncombustion_bituminouscoal_not_europe) - - # CH4 - noncombustion - cokingcoal - air - - Exiobase_TIV_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_cokingcoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_cokingcoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_cokingcoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_cokingcoal_europe,TIV_CH4_noncombustion_cokingcoal_not_europe) - - # CH4 - noncombustion - lignite - air - - Exiobase_TIV_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_lignite_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_lignite_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_lignite_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_lignite_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_lignite_europe,TIV_CH4_noncombustion_lignite_not_europe) - - # CH4 - noncombustion - subbituminouscoal - air - - Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_subbituminouscoal_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_subbituminouscoal_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_subbituminouscoal_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_subbituminouscoal_europe,TIV_CH4_noncombustion_subbituminouscoal_not_europe) - - # CH4 - noncombustion - oilrefinery - air - - Exiobase_TIV_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_noncombustion_oilrefinery_domestic) - - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_noncombustion_oilrefinery_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_noncombustion_oilrefinery_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_noncombustion_oilrefinery_europe,TIV_CH4_noncombustion_oilrefinery_not_europe) - - # CH4 - agriculture - air - - Exiobase_TIV_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_agriculture_domestic) - - Exiobase_TIV_europe_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_agriculture_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_agriculture_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_agriculture_europe,TIV_CH4_agriculture_not_europe) - - # CH4 - waste - air - - Exiobase_TIV_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ch4_CO2eq_waste_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_CH4_waste_domestic) - - Exiobase_TIV_europe_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_", year_current, "_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_CH4_waste_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_CH4_waste_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_CH4_waste_europe,TIV_CH4_waste_not_europe) - - - # N2O - combustion - air - - Exiobase_TIV_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_N2O_domestic) - - Exiobase_TIV_europe_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_N2O_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_N2O_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_N2O_europe,TIV_N2O_not_europe) - - # N2O - agriculture - air - - Exiobase_TIV_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_N2O_agriculture_domestic) - - Exiobase_TIV_europe_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_N2O_agriculture_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_N2O_agriculture_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_N2O_agriculture_europe,TIV_N2O_agriculture_not_europe) - - # SF6 - air - - Exiobase_TIV_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_sf6_CO2eq_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_SF6_domestic) - - Exiobase_TIV_europe_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_sf6_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_SF6_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_SF6_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_SF6_europe,TIV_SF6_not_europe) - - # HFC - air - - Exiobase_TIV_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_hfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_HFC_domestic) - - Exiobase_TIV_europe_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_hfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_HFC_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_HFC_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_HFC_europe,TIV_HFC_not_europe) - - # PFC - air - - Exiobase_TIV_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_pfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_PFC_domestic) - - Exiobase_TIV_europe_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pfc_CO2eq_air_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_PFC_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_PFC_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_PFC_europe,TIV_PFC_not_europe) - - # Energy use - - Exiobase_TIV_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_energy_carrier_use_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_energy_carrier_use_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_energy_domestic) - - Exiobase_TIV_europe_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_energy_carrier_use_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_energy_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_energy_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_energy_europe,TIV_energy_not_europe) - - # biomass - - Exiobase_TIV_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_biomass_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_biomass_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_biomass_domestic) - - Exiobase_TIV_europe_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_biomass_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_biomass_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_biomass_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_biomass_europe,TIV_biomass_not_europe) - - # construction materials - - Exiobase_TIV_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_const_materials_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_const_materials_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_const_materials_domestic) - - Exiobase_TIV_europe_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_const_materials_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_const_materials_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_const_materials_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_const_materials_europe,TIV_const_materials_not_europe) - - # fossil fuels - - Exiobase_TIV_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ffuels_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ffuels_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_ffuels_domestic) - - Exiobase_TIV_europe_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ffuels_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_ffuels_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_ffuels_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_ffuels_europe,TIV_ffuels_not_europe) - - # ores - - Exiobase_TIV_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_ores_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ores_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_ores_domestic) - - Exiobase_TIV_europe_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_ores_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_ores_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_ores_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_ores_europe,TIV_ores_not_europe) - - # cropland - - Exiobase_TIV_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_cropland_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_cropland_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_cropland_domestic) - - Exiobase_TIV_europe_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_cropland_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_cropland_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_cropland_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_cropland_europe,TIV_cropland_not_europe) - - # forest land - - Exiobase_TIV_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_forest_land_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_forest_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_forest_land_domestic) - - Exiobase_TIV_europe_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_forest_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_forest_land_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_forest_land_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_forest_land_europe,TIV_forest_land_not_europe) - - # pasture land - - Exiobase_TIV_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_pasture_land_",year_current,"_ixi.csv"))[,-1] - - Exiobase_TIV_country_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pasture_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - gather(country, TIV_pasture_land_domestic) - - Exiobase_TIV_europe_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, "/IOT_",year_current,"_ixi/TIV_country_breakdown_pasture_land_",year_current,"_ixi.csv"))[,-1] %>% - row_to_names(row_number = 1) %>% - mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %>% - mutate(TIV_pasture_land_europe = AT + - BE + BG + CY + CZ + - DE + DK + EE + - ES + FI + FR + - GB + GR + HR + - HU + IE + IT + - LT + LU + LV + - MT + NL + PL + - PT + TR + SK + - SI + SE + RO + - NO, - TIV_pasture_land_not_europe = AU + - BR + CA + CH + CN + - ID + IN + JP + KR + - MX + RU + TW + US + - WA + WE + WF + WL + WM + - ZA) %>% - select(TIV_pasture_land_europe,TIV_pasture_land_not_europe) - - - # join with labels - - TIV_with_labels = cbind(Exiobase_T_labels, - t(Exiobase_TIV_co2_bp), - t(Exiobase_TIV_co2_noncombustion_cement_bp), - t(Exiobase_TIV_co2_noncombustion_lime_bp), - t(Exiobase_TIV_co2_agriculture_peatdecay_bp), - t(Exiobase_TIV_co2_waste_biogenic_bp), - t(Exiobase_TIV_co2_waste_fossil_bp), - t(Exiobase_TIV_ch4_bp), - t(Exiobase_TIV_ch4_noncombustion_gas_bp), - t(Exiobase_TIV_ch4_noncombustion_oil_bp), - t(Exiobase_TIV_ch4_noncombustion_anthracite_bp), - t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp), - t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp), - t(Exiobase_TIV_ch4_noncombustion_lignite_bp), - t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp), - t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp), - t(Exiobase_TIV_ch4_agriculture_bp), - t(Exiobase_TIV_ch4_waste_bp), - t(Exiobase_TIV_n2o_bp), - t(Exiobase_TIV_n2o_agriculture_bp), - t(Exiobase_TIV_sf6_bp), - t(Exiobase_TIV_hfc_bp), - t(Exiobase_TIV_pfc_bp), - t(Exiobase_TIV_energy_use_bp), - t(Exiobase_TIV_biomass_bp), - t(Exiobase_TIV_const_materials_bp), - t(Exiobase_TIV_ffuels_bp), - t(Exiobase_TIV_ores_bp), - t(Exiobase_TIV_cropland_bp), - t(Exiobase_TIV_forest_land_bp), - t(Exiobase_TIV_pasture_land_bp)) %>% - rename(TIV_CO2 = "t(Exiobase_TIV_co2_bp)", - TIV_CO2_noncombustion_cement = "t(Exiobase_TIV_co2_noncombustion_cement_bp)", - TIV_CO2_noncombustion_lime = "t(Exiobase_TIV_co2_noncombustion_lime_bp)", - TIV_CO2_agriculture_peatdecay = "t(Exiobase_TIV_co2_agriculture_peatdecay_bp)", - TIV_CO2_waste_biogenic = "t(Exiobase_TIV_co2_waste_biogenic_bp)", - TIV_CO2_waste_fossil = "t(Exiobase_TIV_co2_waste_fossil_bp)", - TIV_CH4 = "t(Exiobase_TIV_ch4_bp)", - TIV_CH4_noncombustion_gas = "t(Exiobase_TIV_ch4_noncombustion_gas_bp)", - TIV_CH4_noncombustion_oil = "t(Exiobase_TIV_ch4_noncombustion_oil_bp)", - TIV_CH4_noncombustion_anthracite = "t(Exiobase_TIV_ch4_noncombustion_anthracite_bp)", - TIV_CH4_noncombustion_bituminouscoal = "t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp)", - TIV_CH4_noncombustion_cokingcoal = "t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp)", - TIV_CH4_noncombustion_lignite = "t(Exiobase_TIV_ch4_noncombustion_lignite_bp)", - TIV_CH4_noncombustion_subbituminouscoal = "t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp)", - TIV_CH4_noncombustion_oilrefinery = "t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp)", - TIV_CH4_agriculture = "t(Exiobase_TIV_ch4_agriculture_bp)", - TIV_CH4_waste = "t(Exiobase_TIV_ch4_waste_bp)", - TIV_N2O = "t(Exiobase_TIV_n2o_bp)", - TIV_N2O_agriculture = "t(Exiobase_TIV_n2o_agriculture_bp)", - TIV_SF6 = "t(Exiobase_TIV_sf6_bp)", - TIV_HFC = "t(Exiobase_TIV_hfc_bp)", - TIV_PFC = "t(Exiobase_TIV_pfc_bp)", - TIV_energy = "t(Exiobase_TIV_energy_use_bp)", - TIV_biomass = "t(Exiobase_TIV_biomass_bp)", - TIV_const_materials = "t(Exiobase_TIV_const_materials_bp)", - TIV_ffuels = "t(Exiobase_TIV_ffuels_bp)", - TIV_ores = "t(Exiobase_TIV_ores_bp)", - TIV_cropland = "t(Exiobase_TIV_cropland_bp)", - TIV_forest_land = "t(Exiobase_TIV_forest_land_bp)", - TIV_pasture_land = "t(Exiobase_TIV_pasture_land_bp)") %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year = as.character(rep(year_current,nrow(TIV_with_labels))) - - look = cbind(year,TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2) - - TIVs = rbind(TIVs,look) - - # domestic TIVs - - domestic_TIV_with_labels = cbind(Exiobase_T_labels, - Exiobase_TIV_country_breakdown_co2_bp, - Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp %>% select(-country), - Exiobase_TIV_country_breakdown_co2_waste_fossil_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_agriculture_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ch4_waste_bp %>% select(-country), - Exiobase_TIV_country_breakdown_n2o_bp %>% select(-country), - Exiobase_TIV_country_breakdown_n2o_agriculture_bp %>% select(-country), - Exiobase_TIV_country_breakdown_sf6_bp %>% select(-country), - Exiobase_TIV_country_breakdown_hfc_bp %>% select(-country), - Exiobase_TIV_country_breakdown_pfc_bp %>% select(-country), - Exiobase_TIV_country_breakdown_energy_use_bp %>% select(-country), - Exiobase_TIV_country_breakdown_biomass_bp %>% select(-country), - Exiobase_TIV_country_breakdown_const_materials_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ffuels_bp %>% select(-country), - Exiobase_TIV_country_breakdown_ores_bp %>% select(-country), - Exiobase_TIV_country_breakdown_cropland_bp %>% select(-country), - Exiobase_TIV_country_breakdown_forest_land_bp %>% select(-country), - Exiobase_TIV_country_breakdown_pasture_land_bp %>% select(-country)) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK"), - country = dplyr::recode(country, "GR" = "EL", "GB" = "UK")) - - year_domestic = as.character(rep(year_current,nrow(domestic_TIV_with_labels))) - - look_domestic = cbind(year_domestic,domestic_TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2, geo = country, year = year_domestic) %>% - mutate(TIV_CO2_domestic = as.numeric(TIV_CO2_domestic), - TIV_CO2_noncombustion_cement_domestic = as.numeric(TIV_CO2_noncombustion_cement_domestic), - TIV_CO2_noncombustion_lime_domestic = as.numeric(TIV_CO2_noncombustion_lime_domestic), - TIV_CO2_agriculture_peatdecay_domestic = as.numeric(TIV_CO2_agriculture_peatdecay_domestic), - TIV_CO2_waste_biogenic_domestic = as.numeric(TIV_CO2_waste_biogenic_domestic), - TIV_CO2_waste_fossil_domestic = as.numeric(TIV_CO2_waste_fossil_domestic), - TIV_CH4_domestic = as.numeric(TIV_CH4_domestic), - TIV_CH4_noncombustion_gas_domestic = as.numeric(TIV_CH4_noncombustion_gas_domestic), - TIV_CH4_noncombustion_oil_domestic = as.numeric(TIV_CH4_noncombustion_oil_domestic), - TIV_CH4_noncombustion_anthracite_domestic = as.numeric(TIV_CH4_noncombustion_anthracite_domestic), - TIV_CH4_noncombustion_bituminouscoal_domestic = as.numeric(TIV_CH4_noncombustion_bituminouscoal_domestic), - TIV_CH4_noncombustion_cokingcoal_domestic = as.numeric(TIV_CH4_noncombustion_cokingcoal_domestic), - TIV_CH4_noncombustion_lignite_domestic = as.numeric(TIV_CH4_noncombustion_lignite_domestic), - TIV_CH4_noncombustion_subbituminouscoal_domestic = as.numeric(TIV_CH4_noncombustion_subbituminouscoal_domestic), - TIV_CH4_noncombustion_oilrefinery_domestic = as.numeric(TIV_CH4_noncombustion_oilrefinery_domestic), - TIV_CH4_agriculture_domestic = as.numeric(TIV_CH4_agriculture_domestic), - TIV_CH4_waste_domestic = as.numeric(TIV_CH4_waste_domestic), - TIV_N2O_domestic = as.numeric(TIV_N2O_domestic), - TIV_N2O_agriculture_domestic = as.numeric(TIV_N2O_agriculture_domestic), - TIV_SF6_domestic = as.numeric(TIV_SF6_domestic), - TIV_HFC_domestic = as.numeric(TIV_HFC_domestic), - TIV_PFC_domestic = as.numeric(TIV_PFC_domestic), - TIV_energy_domestic = as.numeric(TIV_energy_domestic), - TIV_biomass_domestic = as.numeric(TIV_biomass_domestic), - TIV_const_materials_domestic = as.numeric(TIV_const_materials_domestic), - TIV_ffuels_domestic = as.numeric(TIV_ffuels_domestic), - TIV_ores_domestic = as.numeric(TIV_ores_domestic), - TIV_cropland_domestic = as.numeric(TIV_cropland_domestic), - TIV_forest_land_domestic = as.numeric(TIV_forest_land_domestic), - TIV_pasture_land_domestic = as.numeric(TIV_pasture_land_domestic)) - - domestic_TIVs = rbind(domestic_TIVs, look_domestic) - - # europe TIVs with labels - - europe_TIV_with_labels = cbind(Exiobase_T_labels, - Exiobase_TIV_europe_breakdown_co2_bp, - Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp, - Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp, - Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp, - Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp, - Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp, - Exiobase_TIV_europe_breakdown_ch4_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp, - Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp, - Exiobase_TIV_europe_breakdown_ch4_agriculture_bp, - Exiobase_TIV_europe_breakdown_ch4_waste_bp, - Exiobase_TIV_europe_breakdown_n2o_bp, - Exiobase_TIV_europe_breakdown_n2o_agriculture_bp, - Exiobase_TIV_europe_breakdown_sf6_bp, - Exiobase_TIV_europe_breakdown_hfc_bp, - Exiobase_TIV_europe_breakdown_pfc_bp, - Exiobase_TIV_europe_breakdown_energy_use_bp, - Exiobase_TIV_europe_breakdown_biomass_bp, - Exiobase_TIV_europe_breakdown_const_materials_bp, - Exiobase_TIV_europe_breakdown_ffuels_bp, - Exiobase_TIV_europe_breakdown_ores_bp, - Exiobase_TIV_europe_breakdown_cropland_bp, - Exiobase_TIV_europe_breakdown_forest_land_bp, - Exiobase_TIV_europe_breakdown_pasture_land_bp) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year_europe = as.character(rep(year_current,nrow(europe_TIV_with_labels))) - - look_europe = cbind(year_europe,europe_TIV_with_labels) %>% - rename(country_of_production = V1, sector = V2, year = year_europe) %>% - mutate(TIV_CO2_europe = as.numeric(TIV_CO2_europe), - TIV_CO2_noncombustion_cement_europe = as.numeric(TIV_CO2_noncombustion_cement_europe), - TIV_CO2_noncombustion_lime_europe = as.numeric(TIV_CO2_noncombustion_lime_europe), - TIV_CO2_agriculture_peatdecay_europe = as.numeric(TIV_CO2_agriculture_peatdecay_europe), - TIV_CO2_waste_biogenic_europe = as.numeric(TIV_CO2_waste_biogenic_europe), - TIV_CO2_waste_fossil_europe = as.numeric(TIV_CO2_waste_fossil_europe), - TIV_CH4_europe = as.numeric(TIV_CH4_europe), - TIV_CH4_noncombustion_gas_europe = as.numeric(TIV_CH4_noncombustion_gas_europe), - TIV_CH4_noncombustion_oil_europe = as.numeric(TIV_CH4_noncombustion_oil_europe), - TIV_CH4_noncombustion_anthracite_europe = as.numeric(TIV_CH4_noncombustion_anthracite_europe), - TIV_CH4_noncombustion_bituminouscoal_europe = as.numeric(TIV_CH4_noncombustion_bituminouscoal_europe), - TIV_CH4_noncombustion_cokingcoal_europe = as.numeric(TIV_CH4_noncombustion_cokingcoal_europe), - TIV_CH4_noncombustion_lignite_europe = as.numeric(TIV_CH4_noncombustion_lignite_europe), - TIV_CH4_noncombustion_subbituminouscoal_europe = as.numeric(TIV_CH4_noncombustion_subbituminouscoal_europe), - TIV_CH4_noncombustion_oilrefinery_europe = as.numeric(TIV_CH4_noncombustion_oilrefinery_europe), - TIV_CH4_agriculture_europe = as.numeric(TIV_CH4_agriculture_europe), - TIV_CH4_waste_europe = as.numeric(TIV_CH4_waste_europe), - TIV_N2O_europe = as.numeric(TIV_N2O_europe), - TIV_N2O_agriculture_europe = as.numeric(TIV_N2O_agriculture_europe), - TIV_SF6_europe = as.numeric(TIV_SF6_europe), - TIV_HFC_europe = as.numeric(TIV_HFC_europe), - TIV_PFC_europe = as.numeric(TIV_PFC_europe), - TIV_energy_europe = as.numeric(TIV_energy_europe), - TIV_biomass_europe = as.numeric(TIV_biomass_europe), - TIV_const_materials_europe = as.numeric(TIV_const_materials_europe), - TIV_ffuels_europe = as.numeric(TIV_ffuels_europe), - TIV_ores_europe = as.numeric(TIV_ores_europe), - TIV_cropland_europe = as.numeric(TIV_cropland_europe), - TIV_forest_land_europe = as.numeric(TIV_forest_land_europe), - TIV_pasture_land_europe = as.numeric(TIV_pasture_land_europe)) - - europe_TIVs = rbind(europe_TIVs, look_europe) - - # total national footprints - - # FD labels - - Exiobase_FD_labels = as.data.frame(t(read.csv(paste0(data_dir_exiobase, "/Exiobase_FD_labels_ixi.csv")))[-1,-3]) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - national_CO2_footprints = Exiobase_FD * t(Exiobase_TIV_co2_bp) - - national_CO2_noncombustion_cement_footprints = Exiobase_FD * t(Exiobase_TIV_co2_noncombustion_cement_bp) - - national_CO2_noncombustion_lime_footprints = Exiobase_FD * t(Exiobase_TIV_co2_noncombustion_lime_bp) - - national_CO2_agriculture_peatdecay_footprints = Exiobase_FD * t(Exiobase_TIV_co2_agriculture_peatdecay_bp) - - national_CO2_waste_biogenic_footprints = Exiobase_FD * t(Exiobase_TIV_co2_waste_biogenic_bp) - - national_CO2_waste_fossil_footprints = Exiobase_FD * t(Exiobase_TIV_co2_waste_fossil_bp) - - national_CH4_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_bp) - - national_CH4_noncombustion_gas_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_gas_bp) - - national_CH4_noncombustion_oil_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_oil_bp) - - national_CH4_noncombustion_anthracite_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_anthracite_bp) - - national_CH4_noncombustion_bituminouscoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp) - - national_CH4_noncombustion_cokingcoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp) - - national_CH4_noncombustion_lignite_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_lignite_bp) - - national_CH4_noncombustion_subbituminouscoal_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp) - - national_CH4_noncombustion_oilrefinery_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp) - - national_CH4_agriculture_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_agriculture_bp) - - national_CH4_waste_footprints = Exiobase_FD * t(Exiobase_TIV_ch4_waste_bp) - - national_N2O_footprints = Exiobase_FD * t(Exiobase_TIV_n2o_bp) - - national_N2O_agriculture_footprints = Exiobase_FD * t(Exiobase_TIV_n2o_agriculture_bp) - - national_SF6_footprints = Exiobase_FD * t(Exiobase_TIV_sf6_bp) - - national_HFC_footprints = Exiobase_FD * t(Exiobase_TIV_hfc_bp) - - national_PFC_footprints = Exiobase_FD * t(Exiobase_TIV_pfc_bp) - - national_energy_footprints = Exiobase_FD * t(Exiobase_TIV_energy_use_bp) - - national_biomass_footprints = Exiobase_FD * t(Exiobase_TIV_biomass_bp) - - national_const_materials_footprints = Exiobase_FD * t(Exiobase_TIV_const_materials_bp) - - national_ffuels_footprints = Exiobase_FD * t(Exiobase_TIV_ffuels_bp) - - national_ores_footprints = Exiobase_FD * t(Exiobase_TIV_ores_bp) - - national_cropland_footprints = Exiobase_FD * t(Exiobase_TIV_cropland_bp) - - national_forest_land_footprints = Exiobase_FD * t(Exiobase_TIV_forest_land_bp) - - national_pasture_land_footprints = Exiobase_FD * t(Exiobase_TIV_pasture_land_bp) - - - # together - - national_footprints_w_labels = cbind(Exiobase_FD_labels, - rowSums(t(national_CO2_footprints)), - rowSums(t(national_CO2_noncombustion_cement_footprints)), - rowSums(t(national_CO2_noncombustion_lime_footprints)), - rowSums(t(national_CO2_agriculture_peatdecay_footprints)), - rowSums(t(national_CO2_waste_biogenic_footprints)), - rowSums(t(national_CO2_waste_fossil_footprints)), - rowSums(t(national_CH4_footprints)), - rowSums(t(national_CH4_noncombustion_gas_footprints)), - rowSums(t(national_CH4_noncombustion_oil_footprints)), - rowSums(t(national_CH4_noncombustion_anthracite_footprints)), - rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints)), - rowSums(t(national_CH4_noncombustion_cokingcoal_footprints)), - rowSums(t(national_CH4_noncombustion_lignite_footprints)), - rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints)), - rowSums(t(national_CH4_noncombustion_oilrefinery_footprints)), - rowSums(t(national_CH4_agriculture_footprints)), - rowSums(t(national_CH4_waste_footprints)), - rowSums(t(national_N2O_footprints)), - rowSums(t(national_N2O_agriculture_footprints)), - rowSums(t(national_SF6_footprints)), - rowSums(t(national_HFC_footprints)), - rowSums(t(national_PFC_footprints)), - rowSums(t(national_energy_footprints)), - rowSums(t(national_biomass_footprints)), - rowSums(t(national_const_materials_footprints)), - rowSums(t(national_ffuels_footprints)), - rowSums(t(national_ores_footprints)), - rowSums(t(national_cropland_footprints)), - rowSums(t(national_forest_land_footprints)), - rowSums(t(national_pasture_land_footprints))) %>% - mutate(V1 = dplyr::recode(V1,"GR" = "EL","GB" = "UK")) - - year_national_fp = as.character(rep(year_current,nrow(national_footprints_w_labels))) - - # direct FD emissions - - direct_FD_extensions = read.csv(paste0(data_dir_exiobase, "/IOT_", year_current, "_ixi/satellite/F_hh.csv", sep = ""),row.names=NULL,as.is=TRUE)[3:1115,3:345] - direct_FD_extensions[is.na(direct_FD_extensions)]=0 - direct_FD_extensions = mapply(direct_FD_extensions, FUN = as.numeric) - direct_FD_extensions = matrix(data=direct_FD_extensions,ncol=343,nrow=1113) - - direct_FD_co2 = direct_FD_extensions[24,] - direct_FD_co2_noncombustion_cement = direct_FD_extensions[93,] - direct_FD_co2_noncombustion_lime = direct_FD_extensions[94,] - direct_FD_co2_agriculture_peatdecay = direct_FD_extensions[428,] - direct_FD_co2_waste_biogenic = direct_FD_extensions[438,] - direct_FD_co2_waste_fossil = direct_FD_extensions[439,] - direct_FD_ch4 = direct_FD_extensions[25,]*28 - direct_FD_ch4_noncombustion_gas = direct_FD_extensions[68,]*28 - direct_FD_ch4_noncombustion_oil = direct_FD_extensions[69,]*28 - direct_FD_ch4_noncombustion_anthracite = direct_FD_extensions[70,]*28 - direct_FD_ch4_noncombustion_bituminouscoal = direct_FD_extensions[71,]*28 - direct_FD_ch4_noncombustion_cokingcoal = direct_FD_extensions[72,]*28 - direct_FD_ch4_noncombustion_lignite = direct_FD_extensions[73,]*28 - direct_FD_ch4_noncombustion_subbituminouscoal = direct_FD_extensions[74,]*28 - direct_FD_ch4_noncombustion_oilrefinery = direct_FD_extensions[75,]*28 - direct_FD_ch4_agriculture = direct_FD_extensions[427,]*28 - direct_FD_ch4_waste = direct_FD_extensions[436,]*28 - direct_FD_n2o = direct_FD_extensions[26,]*265 - direct_FD_n2o_agriculture = direct_FD_extensions[430,]*265 - direct_FD_sf6 = direct_FD_extensions[424,]*23500 - direct_FD_hfc = direct_FD_extensions[425,] - direct_FD_pfc = direct_FD_extensions[426,] - direct_FD_energy = direct_FD_extensions[470,] - direct_FD_biomass = colSums(direct_FD_extensions[c(471:499,501,522:688),]) - direct_FD_const_materials = colSums(direct_FD_extensions[514:521,]) - direct_FD_ffuels = direct_FD_extensions[500,] - direct_FD_ores = colSums(direct_FD_extensions[502:513,]) - direct_FD_cropland = colSums(direct_FD_extensions[447:459,]) - direct_FD_forest_land = colSums(direct_FD_extensions[c(460,466),]) - direct_FD_pasture_land = colSums(direct_FD_extensions[462:464,]) - - - direct_FD_fp = data.frame(direct_FD_co2, - direct_FD_co2_noncombustion_cement, - direct_FD_co2_noncombustion_lime, - direct_FD_co2_agriculture_peatdecay, - direct_FD_co2_waste_biogenic, - direct_FD_co2_waste_fossil, - direct_FD_ch4, - direct_FD_ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_oilrefinery, - direct_FD_ch4_agriculture, - direct_FD_ch4_waste, - direct_FD_n2o, - direct_FD_n2o_agriculture, - direct_FD_sf6, - direct_FD_hfc, - direct_FD_pfc, - direct_FD_energy, - direct_FD_biomass, - direct_FD_const_materials, - direct_FD_ffuels, - direct_FD_ores, - direct_FD_cropland, - direct_FD_forest_land, - direct_FD_pasture_land) - - look_national_fp = as.data.frame(cbind(year_national_fp, - national_footprints_w_labels, - direct_FD_fp)) %>% - rename(year = year_national_fp, - geo = V1, - fd_category = V2, - co2 = "rowSums(t(national_CO2_footprints))", - co2_noncombustion_cement = "rowSums(t(national_CO2_noncombustion_cement_footprints))", - co2_noncombustion_lime = "rowSums(t(national_CO2_noncombustion_lime_footprints))", - co2_agriculture_peatdecay = "rowSums(t(national_CO2_agriculture_peatdecay_footprints))", - co2_waste_biogenic = "rowSums(t(national_CO2_waste_biogenic_footprints))", - co2_waste_fossil = "rowSums(t(national_CO2_waste_fossil_footprints))", - ch4 = "rowSums(t(national_CH4_footprints))", - ch4_noncombustion_gas = "rowSums(t(national_CH4_noncombustion_gas_footprints))", - ch4_noncombustion_oil = "rowSums(t(national_CH4_noncombustion_oil_footprints))", - ch4_noncombustion_anthracite = "rowSums(t(national_CH4_noncombustion_anthracite_footprints))", - ch4_noncombustion_bituminouscoal = "rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints))", - ch4_noncombustion_cokingcoal = "rowSums(t(national_CH4_noncombustion_cokingcoal_footprints))", - ch4_noncombustion_lignite = "rowSums(t(national_CH4_noncombustion_lignite_footprints))", - ch4_noncombustion_subbituminouscoal = "rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints))", - ch4_noncombustion_oilrefinery = "rowSums(t(national_CH4_noncombustion_oilrefinery_footprints))", - ch4_agriculture = "rowSums(t(national_CH4_agriculture_footprints))", - ch4_waste = "rowSums(t(national_CH4_waste_footprints))", - n2o = "rowSums(t(national_N2O_footprints))", - n2o_agriculture = "rowSums(t(national_N2O_agriculture_footprints))", - sf6 = "rowSums(t(national_SF6_footprints))", - hfc = "rowSums(t(national_HFC_footprints))", - pfc = "rowSums(t(national_PFC_footprints))", - energy = "rowSums(t(national_energy_footprints))", - biomass = "rowSums(t(national_biomass_footprints))", - const_materials = "rowSums(t(national_const_materials_footprints))", - ffuels = "rowSums(t(national_ffuels_footprints))", - ores = "rowSums(t(national_ores_footprints))", - cropland = "rowSums(t(national_cropland_footprints))", - forest_land = "rowSums(t(national_forest_land_footprints))", - pasture_land = "rowSums(t(national_pasture_land_footprints))") %>% - select(year, - geo, - fd_category, - co2, - direct_FD_co2, - co2_noncombustion_cement, - direct_FD_co2_noncombustion_cement, - co2_noncombustion_lime, - direct_FD_co2_noncombustion_lime, - co2_agriculture_peatdecay, - direct_FD_co2_agriculture_peatdecay, - co2_waste_biogenic, - direct_FD_co2_waste_biogenic, - co2_waste_fossil, - direct_FD_co2_waste_fossil, - ch4, - direct_FD_ch4, - ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_gas, - ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_oil, - ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_anthracite, - ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_bituminouscoal, - ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_cokingcoal, - ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_lignite, - ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_subbituminouscoal, - ch4_noncombustion_oilrefinery, - direct_FD_ch4_noncombustion_oilrefinery, - ch4_agriculture, - direct_FD_ch4_agriculture, - ch4_waste, - direct_FD_ch4_waste, - n2o, - direct_FD_n2o, - n2o_agriculture, - direct_FD_n2o_agriculture, - sf6, - direct_FD_sf6, - hfc, - direct_FD_hfc, - pfc, - direct_FD_pfc, - energy, - direct_FD_energy, - biomass, - direct_FD_biomass, - const_materials, - direct_FD_const_materials, - ffuels, - direct_FD_ffuels, - ores, - direct_FD_ores, - cropland, - direct_FD_cropland, - forest_land, - direct_FD_forest_land, - pasture_land, - direct_FD_pasture_land) - - - national_fp = rbind(national_fp, look_national_fp) - - -} - - - -# option holding HBS exp ratios - -mean_expenditure_by_quintile_toggle = mean_expenditure_by_quintile_long_bp %>% - filter(!(quintile %in% c("TOTAL","UNK"))) %>% - group_by(geo,year) %>% - mutate(euro_pps_bp = as.numeric(euro_pps_bp), - mean_exp_shares = euro_pps_bp/sum(euro_pps_bp)) - - -ala = total_fd %>% - left_join(mean_expenditure_by_quintile_toggle, by = c("geo","year","quintile")) - - - -join_ala = mean_expenditure_by_coicop_sector_long_bp %>% - left_join(ala, by = c("geo","quintile","year")) %>% - mutate(year = as.numeric(year), - eurostat_countries_colsums = as.numeric(eurostat_countries_colsums), - pm_bp = as.numeric(pm_bp), - fd_me = pm_bp*((eurostat_countries_colsums*mean_exp_shares)/1000)) - - -################################################### -#%>% -# rename(coicop_level1 = coicop) - -# TIV only taking the mean - -# mean_TIV_with_labels = TIV_with_labels %>% group_by(geo,year,coicop,coicop_level1) %>% -# summarise(TIV_CO2 = mean(TIV_CO2)) - -#ok = join_ala %>% left_join(mean_TIV_with_labels, by = c("geo","year","coicop")) %>% -# mutate(CO2_normal = exp_normal*TIV_CO2, -# CO2_pe = exp_pe*TIV_CO2, -# CO2_pi = exp_pi*TIV_CO2) -################################################## - -Eurostat_countries_hh_fd_mean_TIV = as.data.frame(Eurostat_countries_hh_fd) %>% select(-year) - -weighted_mean_TIV_with_labels = cbind(TIVs,Eurostat_countries_hh_fd_mean_TIV) %>% - gather(geo,fd,-country_of_production,-year,-sector,-coicop,-five_sectors, - -TIV_CO2,-TIV_CO2_noncombustion_cement,-TIV_CO2_noncombustion_lime, - -TIV_CO2_agriculture_peatdecay,-TIV_CO2_waste_biogenic, - -TIV_CO2_waste_fossil,-TIV_CH4, - -TIV_CH4_noncombustion_gas,-TIV_CH4_noncombustion_oil, - -TIV_CH4_noncombustion_anthracite,-TIV_CH4_noncombustion_bituminouscoal, - -TIV_CH4_noncombustion_cokingcoal,-TIV_CH4_noncombustion_lignite, - -TIV_CH4_noncombustion_subbituminouscoal,-TIV_CH4_noncombustion_oilrefinery, - -TIV_CH4_agriculture,-TIV_CH4_waste, - -TIV_N2O,-TIV_N2O_agriculture,-TIV_SF6,-TIV_HFC,-TIV_PFC, - -TIV_energy,-TIV_biomass,-TIV_const_materials,-TIV_ffuels, - -TIV_ores,-TIV_cropland,-TIV_forest_land,-TIV_pasture_land) %>% - group_by(geo,year,coicop) %>% - mutate(fd = as.numeric(fd)) %>% - mutate(TIV_CO2_weighted_average = sum((fd/sum(fd))*TIV_CO2), - TIV_CO2_noncombustion_cement_weighted_average = sum((fd/sum(fd))*TIV_CO2_noncombustion_cement), - TIV_CO2_noncombustion_lime_weighted_average = sum((fd/sum(fd))*TIV_CO2_noncombustion_lime), - TIV_CO2_agriculture_peatdecay_weighted_average = sum((fd/sum(fd))*TIV_CO2_agriculture_peatdecay), - TIV_CO2_waste_biogenic_weighted_average = sum((fd/sum(fd))*TIV_CO2_waste_biogenic), - TIV_CO2_waste_fossil_weighted_average = sum((fd/sum(fd))*TIV_CO2_waste_fossil), - TIV_CH4_weighted_average = sum((fd/sum(fd))*TIV_CH4), - TIV_CH4_noncombustion_gas_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_gas), - TIV_CH4_noncombustion_oil_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_oil), - TIV_CH4_noncombustion_anthracite_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_anthracite), - TIV_CH4_noncombustion_bituminouscoal_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_bituminouscoal), - TIV_CH4_noncombustion_cokingcoal_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_cokingcoal), - TIV_CH4_noncombustion_lignite_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_lignite), - TIV_CH4_noncombustion_subbituminouscoal_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_subbituminouscoal), - TIV_CH4_noncombustion_oilrefinery_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_oilrefinery), - TIV_CH4_agriculture_weighted_average = sum((fd/sum(fd))*TIV_CH4_agriculture), - TIV_CH4_waste_weighted_average = sum((fd/sum(fd))*TIV_CH4_waste), - TIV_N2O_weighted_average = sum((fd/sum(fd))*TIV_N2O), - TIV_N2O_agriculture_weighted_average = sum((fd/sum(fd))*TIV_N2O_agriculture), - TIV_SF6_weighted_average = sum((fd/sum(fd))*TIV_SF6), - TIV_HFC_weighted_average = sum((fd/sum(fd))*TIV_HFC), - TIV_PFC_weighted_average = sum((fd/sum(fd))*TIV_PFC), - TIV_energy_weighted_average = sum((fd/sum(fd))*TIV_energy), - TIV_biomass_weighted_average = sum((fd/sum(fd))*TIV_biomass), - TIV_const_materials_weighted_average = sum((fd/sum(fd))*TIV_const_materials), - TIV_ffuels_weighted_average = sum((fd/sum(fd))*TIV_ffuels), - TIV_ores_weighted_average = sum((fd/sum(fd))*TIV_ores), - TIV_cropland_weighted_average = sum((fd/sum(fd))*TIV_cropland), - TIV_forest_land_weighted_average = sum((fd/sum(fd))*TIV_forest_land), - TIV_pasture_land_weighted_average = sum((fd/sum(fd))*TIV_pasture_land)) %>% - select(year,geo,coicop,TIV_CO2_weighted_average, - TIV_CO2_noncombustion_cement_weighted_average, - TIV_CO2_noncombustion_lime_weighted_average, - TIV_CO2_agriculture_peatdecay_weighted_average, - TIV_CO2_waste_biogenic_weighted_average, - TIV_CO2_waste_fossil_weighted_average, - TIV_CH4_weighted_average, - TIV_CH4_noncombustion_gas_weighted_average, - TIV_CH4_noncombustion_oil_weighted_average, - TIV_CH4_noncombustion_anthracite_weighted_average, - TIV_CH4_noncombustion_bituminouscoal_weighted_average, - TIV_CH4_noncombustion_cokingcoal_weighted_average, - TIV_CH4_noncombustion_lignite_weighted_average, - TIV_CH4_noncombustion_subbituminouscoal_weighted_average, - TIV_CH4_noncombustion_oilrefinery_weighted_average, - TIV_CH4_agriculture_weighted_average, - TIV_CH4_waste_weighted_average, - TIV_N2O_weighted_average, - TIV_N2O_agriculture_weighted_average, - TIV_SF6_weighted_average, - TIV_HFC_weighted_average, - TIV_PFC_weighted_average, - TIV_energy_weighted_average, - TIV_biomass_weighted_average, - TIV_const_materials_weighted_average, - TIV_ffuels_weighted_average, - TIV_ores_weighted_average, - TIV_cropland_weighted_average, - TIV_forest_land_weighted_average, - TIV_pasture_land_weighted_average) %>% - unique() - -weighted_mean_europe_TIV_with_labels = cbind(europe_TIVs, Eurostat_countries_hh_fd_mean_TIV) %>% - gather(geo,fd,-country_of_production,-year,-sector,-coicop,-five_sectors, - -TIV_CO2_europe,-TIV_CO2_not_europe, - -TIV_CO2_noncombustion_cement_europe,-TIV_CO2_noncombustion_cement_not_europe, - -TIV_CO2_noncombustion_lime_europe, -TIV_CO2_noncombustion_lime_not_europe, - -TIV_CO2_agriculture_peatdecay_europe,-TIV_CO2_agriculture_peatdecay_not_europe, - -TIV_CO2_waste_biogenic_europe, -TIV_CO2_waste_biogenic_not_europe, - -TIV_CO2_waste_fossil_europe, -TIV_CO2_waste_fossil_not_europe, - -TIV_CH4_europe,-TIV_CH4_not_europe, - -TIV_CH4_noncombustion_gas_europe, -TIV_CH4_noncombustion_gas_not_europe, - -TIV_CH4_noncombustion_oil_europe,-TIV_CH4_noncombustion_oil_not_europe, - -TIV_CH4_noncombustion_anthracite_europe,-TIV_CH4_noncombustion_anthracite_not_europe, - -TIV_CH4_noncombustion_bituminouscoal_europe,-TIV_CH4_noncombustion_bituminouscoal_not_europe, - -TIV_CH4_noncombustion_cokingcoal_europe,-TIV_CH4_noncombustion_cokingcoal_not_europe, - -TIV_CH4_noncombustion_lignite_europe,-TIV_CH4_noncombustion_lignite_not_europe, - -TIV_CH4_noncombustion_subbituminouscoal_europe,-TIV_CH4_noncombustion_subbituminouscoal_not_europe, - -TIV_CH4_noncombustion_oilrefinery_europe, -TIV_CH4_noncombustion_oilrefinery_not_europe, - -TIV_CH4_agriculture_europe, -TIV_CH4_agriculture_not_europe, - -TIV_CH4_waste_europe,-TIV_CH4_waste_not_europe, - -TIV_N2O_europe,-TIV_N2O_not_europe, - -TIV_N2O_agriculture_europe,-TIV_N2O_agriculture_not_europe, - -TIV_SF6_europe,-TIV_SF6_not_europe, - -TIV_HFC_europe,-TIV_HFC_not_europe,-TIV_PFC_europe,-TIV_PFC_not_europe, - -TIV_energy_europe,-TIV_energy_not_europe,-TIV_biomass_europe,-TIV_biomass_not_europe, - -TIV_const_materials_europe,-TIV_const_materials_not_europe,-TIV_ffuels_europe,-TIV_ffuels_not_europe, - -TIV_ores_europe,-TIV_ores_not_europe,-TIV_cropland_europe,-TIV_cropland_not_europe, - -TIV_forest_land_europe,-TIV_forest_land_not_europe,-TIV_pasture_land_europe,-TIV_pasture_land_not_europe) %>% - group_by(geo,year,coicop) %>% - mutate(fd = as.numeric(fd)) %>% - mutate(TIV_CO2_europe_weighted_average = sum((fd/sum(fd))*TIV_CO2_europe), - TIV_CO2_noncombustion_cement_europe_weighted_average = sum((fd/sum(fd))*TIV_CO2_noncombustion_cement_europe), - TIV_CO2_noncombustion_lime_europe_weighted_average = sum((fd/sum(fd))*TIV_CO2_noncombustion_lime_europe), - TIV_CO2_agriculture_peatdecay_europe_weighted_average = sum((fd/sum(fd))*TIV_CO2_agriculture_peatdecay_europe), - TIV_CO2_waste_biogenic_europe_weighted_average = sum((fd/sum(fd))*TIV_CO2_waste_biogenic_europe), - TIV_CO2_waste_fossil_europe_weighted_average = sum((fd/sum(fd))*TIV_CO2_waste_fossil_europe), - TIV_CH4_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_europe), - TIV_CH4_noncombustion_gas_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_gas_europe), - TIV_CH4_noncombustion_oil_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_oil_europe), - TIV_CH4_noncombustion_anthracite_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_anthracite_europe), - TIV_CH4_noncombustion_bituminouscoal_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_bituminouscoal_europe), - TIV_CH4_noncombustion_cokingcoal_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_cokingcoal_europe), - TIV_CH4_noncombustion_lignite_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_lignite_europe), - TIV_CH4_noncombustion_subbituminouscoal_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_subbituminouscoal_europe), - TIV_CH4_noncombustion_oilrefinery_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_oilrefinery_europe), - TIV_CH4_agriculture_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_agriculture_europe), - TIV_CH4_waste_europe_weighted_average = sum((fd/sum(fd))*TIV_CH4_waste_europe), - TIV_N2O_europe_weighted_average = sum((fd/sum(fd))*TIV_N2O_europe), - TIV_N2O_agriculture_europe_weighted_average = sum((fd/sum(fd))*TIV_N2O_agriculture_europe), - TIV_SF6_europe_weighted_average = sum((fd/sum(fd))*TIV_SF6_europe), - TIV_HFC_europe_weighted_average = sum((fd/sum(fd))*TIV_HFC_europe), - TIV_PFC_europe_weighted_average = sum((fd/sum(fd))*TIV_PFC_europe), - TIV_energy_europe_weighted_average = sum((fd/sum(fd))*TIV_energy_europe), - TIV_biomass_europe_weighted_average = sum((fd/sum(fd))*TIV_biomass_europe), - TIV_const_materials_europe_weighted_average = sum((fd/sum(fd))*TIV_const_materials_europe), - TIV_ffuels_europe_weighted_average = sum((fd/sum(fd))*TIV_ffuels_europe), - TIV_ores_europe_weighted_average = sum((fd/sum(fd))*TIV_ores_europe), - TIV_cropland_europe_weighted_average = sum((fd/sum(fd))*TIV_cropland_europe), - TIV_forest_land_europe_weighted_average = sum((fd/sum(fd))*TIV_forest_land_europe), - TIV_pasture_land_europe_weighted_average = sum((fd/sum(fd))*TIV_pasture_land_europe)) %>% - select(year,geo,coicop,TIV_CO2_europe_weighted_average, - TIV_CO2_noncombustion_cement_europe_weighted_average, - TIV_CO2_noncombustion_lime_europe_weighted_average, - TIV_CO2_agriculture_peatdecay_europe_weighted_average, - TIV_CO2_waste_biogenic_europe_weighted_average, - TIV_CO2_waste_fossil_europe_weighted_average, - TIV_CH4_europe_weighted_average, - TIV_CH4_noncombustion_gas_europe_weighted_average, - TIV_CH4_noncombustion_oil_europe_weighted_average, - TIV_CH4_noncombustion_anthracite_europe_weighted_average, - TIV_CH4_noncombustion_bituminouscoal_europe_weighted_average, - TIV_CH4_noncombustion_cokingcoal_europe_weighted_average, - TIV_CH4_noncombustion_lignite_europe_weighted_average, - TIV_CH4_noncombustion_subbituminouscoal_europe_weighted_average, - TIV_CH4_noncombustion_oilrefinery_europe_weighted_average, - TIV_CH4_agriculture_europe_weighted_average, - TIV_CH4_waste_europe_weighted_average, - TIV_N2O_europe_weighted_average, - TIV_N2O_agriculture_europe_weighted_average, - TIV_SF6_europe_weighted_average, - TIV_HFC_europe_weighted_average, - TIV_PFC_europe_weighted_average, - TIV_energy_europe_weighted_average, - TIV_biomass_europe_weighted_average, - TIV_const_materials_europe_weighted_average, - TIV_ffuels_europe_weighted_average, - TIV_ores_europe_weighted_average, - TIV_cropland_europe_weighted_average, - TIV_forest_land_europe_weighted_average, - TIV_pasture_land_europe_weighted_average) %>% - unique() - -domestic_TIVs_Eurostat = domestic_TIVs %>% - filter(geo %in% c("AT", - "BG", - "BE", - "CY", - "CZ", - "DE", - "DK", - "EE", - "EL", - "ES", - "FI", - "FR", - "HR", - "HU", - "IE", - "IT", - "LT", - "LU", - "LV", - "MT", - "NL", - "NO", - "PL", - "PT", - "RO", - "SE", - "SI", - "SK", - "TR", - "UK")) - -Eurostat_countries_hh_fd_long = as.data.frame(Eurostat_countries_hh_fd) %>% - gather(geo,fd,-year) %>% - arrange(year, match(geo, c("AT", - "BE", - "BG", - "CY", - "CZ", - "DE", - "DK", - "EE", - "ES", - "FI", - "FR", - "UK", - "EL", - "HR", - "HU", - "IE", - "IT", - "LT", - "LU", - "LV", - "MT", - "NL", - "NO", - "PL", - "PT", - "RO", - "SE", - "SI", - "SK", - "TR"))) %>% select(-year,-geo) - -weighted_mean_domestic_TIV_with_labels = cbind(domestic_TIVs_Eurostat,Eurostat_countries_hh_fd_long) %>% - group_by(geo,year,coicop) %>% - mutate(fd = as.numeric(fd)) %>% - mutate(TIV_CO2_domestic_weighted_average = sum((fd/sum(fd))*TIV_CO2_domestic), - TIV_CO2_noncombustion_cement_domestic_weighted_average = sum((fd/sum(fd))*TIV_CO2_noncombustion_cement_domestic), - TIV_CO2_noncombustion_lime_domestic_weighted_average = sum((fd/sum(fd))*TIV_CO2_noncombustion_lime_domestic), - TIV_CO2_agriculture_peatdecay_domestic_weighted_average = sum((fd/sum(fd))*TIV_CO2_agriculture_peatdecay_domestic), - TIV_CO2_waste_biogenic_domestic_weighted_average = sum((fd/sum(fd))*TIV_CO2_waste_biogenic_domestic), - TIV_CO2_waste_fossil_domestic_weighted_average = sum((fd/sum(fd))*TIV_CO2_waste_fossil_domestic), - TIV_CH4_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_domestic), - TIV_CH4_noncombustion_gas_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_gas_domestic), - TIV_CH4_noncombustion_oil_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_oil_domestic), - TIV_CH4_noncombustion_anthracite_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_anthracite_domestic), - TIV_CH4_noncombustion_bituminouscoal_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_bituminouscoal_domestic), - TIV_CH4_noncombustion_cokingcoal_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_cokingcoal_domestic), - TIV_CH4_noncombustion_lignite_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_lignite_domestic), - TIV_CH4_noncombustion_subbituminouscoal_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_subbituminouscoal_domestic), - TIV_CH4_noncombustion_oilrefinery_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_noncombustion_oilrefinery_domestic), - TIV_CH4_agriculture_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_agriculture_domestic), - TIV_CH4_waste_domestic_weighted_average = sum((fd/sum(fd))*TIV_CH4_waste_domestic), - TIV_N2O_domestic_weighted_average = sum((fd/sum(fd))*TIV_N2O_domestic), - TIV_N2O_agriculture_domestic_weighted_average = sum((fd/sum(fd))*TIV_N2O_agriculture_domestic), - TIV_SF6_domestic_weighted_average = sum((fd/sum(fd))*TIV_SF6_domestic), - TIV_HFC_domestic_weighted_average = sum((fd/sum(fd))*TIV_HFC_domestic), - TIV_PFC_domestic_weighted_average = sum((fd/sum(fd))*TIV_PFC_domestic), - TIV_energy_domestic_weighted_average = sum((fd/sum(fd))*TIV_energy_domestic), - TIV_biomass_domestic_weighted_average = sum((fd/sum(fd))*TIV_biomass_domestic), - TIV_const_materials_domestic_weighted_average = sum((fd/sum(fd))*TIV_const_materials_domestic), - TIV_ffuels_domestic_weighted_average = sum((fd/sum(fd))*TIV_ffuels_domestic), - TIV_ores_domestic_weighted_average = sum((fd/sum(fd))*TIV_ores_domestic), - TIV_cropland_domestic_weighted_average = sum((fd/sum(fd))*TIV_cropland_domestic), - TIV_forest_land_domestic_weighted_average = sum((fd/sum(fd))*TIV_forest_land_domestic), - TIV_pasture_land_domestic_weighted_average = sum((fd/sum(fd))*TIV_pasture_land_domestic)) %>% - select(year,geo,coicop,TIV_CO2_domestic_weighted_average, - TIV_CO2_noncombustion_cement_domestic_weighted_average, - TIV_CO2_noncombustion_lime_domestic_weighted_average, - TIV_CO2_agriculture_peatdecay_domestic_weighted_average, - TIV_CO2_waste_biogenic_domestic_weighted_average, - TIV_CO2_waste_fossil_domestic_weighted_average, - TIV_CH4_domestic_weighted_average, - TIV_CH4_noncombustion_gas_domestic_weighted_average, - TIV_CH4_noncombustion_oil_domestic_weighted_average, - TIV_CH4_noncombustion_anthracite_domestic_weighted_average, - TIV_CH4_noncombustion_bituminouscoal_domestic_weighted_average, - TIV_CH4_noncombustion_cokingcoal_domestic_weighted_average, - TIV_CH4_noncombustion_lignite_domestic_weighted_average, - TIV_CH4_noncombustion_subbituminouscoal_domestic_weighted_average, - TIV_CH4_noncombustion_oilrefinery_domestic_weighted_average, - TIV_CH4_agriculture_domestic_weighted_average, - TIV_CH4_waste_domestic_weighted_average, - TIV_N2O_domestic_weighted_average, - TIV_N2O_agriculture_domestic_weighted_average, - TIV_SF6_domestic_weighted_average, - TIV_HFC_domestic_weighted_average, - TIV_PFC_domestic_weighted_average, - TIV_energy_domestic_weighted_average, - TIV_biomass_domestic_weighted_average, - TIV_const_materials_domestic_weighted_average, - TIV_ffuels_domestic_weighted_average, - TIV_ores_domestic_weighted_average, - TIV_cropland_domestic_weighted_average, - TIV_forest_land_domestic_weighted_average, - TIV_pasture_land_domestic_weighted_average) %>% - unique() - - - - - -ok = join_ala %>% - mutate(year = as.character(year)) %>% - left_join(weighted_mean_TIV_with_labels, by = c("geo","year","coicop")) %>% - left_join(weighted_mean_europe_TIV_with_labels, by = c("geo","year","coicop")) %>% - left_join(weighted_mean_domestic_TIV_with_labels, by = c("geo", "year", "coicop")) %>% - mutate(co2_kg = fd_me*(TIV_CO2_weighted_average + TIV_CO2_noncombustion_cement_weighted_average + - TIV_CO2_noncombustion_lime_weighted_average + TIV_CO2_agriculture_peatdecay_weighted_average + - TIV_CO2_waste_biogenic_weighted_average + TIV_CO2_waste_fossil_weighted_average), - co2_domestic_kg = fd_me*(TIV_CO2_domestic_weighted_average + TIV_CO2_noncombustion_cement_domestic_weighted_average + - TIV_CO2_noncombustion_lime_domestic_weighted_average + TIV_CO2_agriculture_peatdecay_domestic_weighted_average + - TIV_CO2_waste_biogenic_domestic_weighted_average + TIV_CO2_waste_fossil_domestic_weighted_average), - co2_europe_kg = fd_me*((TIV_CO2_europe_weighted_average + TIV_CO2_noncombustion_cement_europe_weighted_average + - TIV_CO2_noncombustion_lime_europe_weighted_average + TIV_CO2_agriculture_peatdecay_europe_weighted_average + - TIV_CO2_waste_biogenic_europe_weighted_average + TIV_CO2_waste_fossil_europe_weighted_average) - (TIV_CO2_domestic_weighted_average + TIV_CO2_noncombustion_cement_domestic_weighted_average + - TIV_CO2_noncombustion_lime_domestic_weighted_average + TIV_CO2_agriculture_peatdecay_domestic_weighted_average + - TIV_CO2_waste_biogenic_domestic_weighted_average + TIV_CO2_waste_fossil_domestic_weighted_average)), - co2eq_kg = fd_me*(TIV_CO2_weighted_average + - TIV_CO2_noncombustion_cement_weighted_average + - TIV_CO2_noncombustion_lime_weighted_average + TIV_CO2_agriculture_peatdecay_weighted_average + - TIV_CO2_waste_biogenic_weighted_average + TIV_CO2_waste_fossil_weighted_average + - TIV_CH4_weighted_average + - TIV_CH4_noncombustion_gas_weighted_average + - TIV_CH4_noncombustion_oil_weighted_average + - TIV_CH4_noncombustion_anthracite_weighted_average + - TIV_CH4_noncombustion_bituminouscoal_weighted_average + - TIV_CH4_noncombustion_cokingcoal_weighted_average + - TIV_CH4_noncombustion_lignite_weighted_average + - TIV_CH4_noncombustion_subbituminouscoal_weighted_average + - TIV_CH4_noncombustion_oilrefinery_weighted_average + - TIV_CH4_agriculture_weighted_average + - TIV_CH4_waste_weighted_average + - TIV_N2O_weighted_average + - TIV_N2O_agriculture_weighted_average + - TIV_SF6_weighted_average + - TIV_HFC_weighted_average + - TIV_PFC_weighted_average), - co2eq_domestic_kg = fd_me*(TIV_CO2_domestic_weighted_average + - TIV_CO2_noncombustion_cement_domestic_weighted_average + - TIV_CO2_noncombustion_lime_domestic_weighted_average + TIV_CO2_agriculture_peatdecay_domestic_weighted_average + - TIV_CO2_waste_biogenic_domestic_weighted_average + TIV_CO2_waste_fossil_domestic_weighted_average + - TIV_CH4_domestic_weighted_average + - TIV_CH4_noncombustion_gas_domestic_weighted_average + - TIV_CH4_noncombustion_oil_domestic_weighted_average + - TIV_CH4_noncombustion_anthracite_domestic_weighted_average + - TIV_CH4_noncombustion_bituminouscoal_domestic_weighted_average + - TIV_CH4_noncombustion_cokingcoal_domestic_weighted_average + - TIV_CH4_noncombustion_lignite_domestic_weighted_average + - TIV_CH4_noncombustion_subbituminouscoal_domestic_weighted_average + - TIV_CH4_noncombustion_oilrefinery_domestic_weighted_average + - TIV_CH4_agriculture_domestic_weighted_average + - TIV_CH4_waste_domestic_weighted_average + - TIV_N2O_domestic_weighted_average + - TIV_N2O_agriculture_domestic_weighted_average + - TIV_SF6_domestic_weighted_average + - TIV_HFC_domestic_weighted_average + - TIV_PFC_domestic_weighted_average), - co2eq_europe_kg = fd_me*((TIV_CO2_europe_weighted_average + - TIV_CO2_noncombustion_cement_europe_weighted_average + - TIV_CO2_noncombustion_lime_europe_weighted_average + TIV_CO2_agriculture_peatdecay_europe_weighted_average + - TIV_CO2_waste_biogenic_europe_weighted_average + TIV_CO2_waste_fossil_europe_weighted_average + - TIV_CH4_europe_weighted_average + - TIV_CH4_noncombustion_gas_europe_weighted_average + - TIV_CH4_noncombustion_oil_europe_weighted_average + - TIV_CH4_noncombustion_anthracite_europe_weighted_average + - TIV_CH4_noncombustion_bituminouscoal_europe_weighted_average + - TIV_CH4_noncombustion_cokingcoal_europe_weighted_average + - TIV_CH4_noncombustion_lignite_europe_weighted_average + - TIV_CH4_noncombustion_subbituminouscoal_europe_weighted_average + - TIV_CH4_noncombustion_oilrefinery_europe_weighted_average + - TIV_CH4_agriculture_europe_weighted_average + - TIV_CH4_waste_europe_weighted_average + - TIV_N2O_europe_weighted_average + - TIV_N2O_agriculture_europe_weighted_average + - TIV_SF6_europe_weighted_average + - TIV_HFC_europe_weighted_average + - TIV_PFC_europe_weighted_average) - - (TIV_CO2_domestic_weighted_average + - TIV_CO2_noncombustion_cement_domestic_weighted_average + - TIV_CO2_noncombustion_lime_domestic_weighted_average + TIV_CO2_agriculture_peatdecay_domestic_weighted_average + - TIV_CO2_waste_biogenic_domestic_weighted_average + TIV_CO2_waste_fossil_domestic_weighted_average + - TIV_CH4_domestic_weighted_average + - TIV_CH4_noncombustion_gas_domestic_weighted_average + - TIV_CH4_noncombustion_oil_domestic_weighted_average + - TIV_CH4_noncombustion_anthracite_domestic_weighted_average + - TIV_CH4_noncombustion_bituminouscoal_domestic_weighted_average + - TIV_CH4_noncombustion_cokingcoal_domestic_weighted_average + - TIV_CH4_noncombustion_lignite_domestic_weighted_average + - TIV_CH4_noncombustion_subbituminouscoal_domestic_weighted_average + - TIV_CH4_noncombustion_oilrefinery_domestic_weighted_average + - TIV_CH4_agriculture_domestic_weighted_average + - TIV_CH4_waste_domestic_weighted_average + - TIV_N2O_domestic_weighted_average + - TIV_N2O_agriculture_domestic_weighted_average + - TIV_SF6_domestic_weighted_average + - TIV_HFC_domestic_weighted_average + - TIV_PFC_domestic_weighted_average)), - energy_use_TJ = fd_me*(TIV_energy_weighted_average), - energy_use_domestic_TJ = fd_me*(TIV_energy_domestic_weighted_average), - energy_use_europe_TJ = fd_me*(TIV_energy_europe_weighted_average - - TIV_energy_domestic_weighted_average)) - -# direct from FD - to go back to results without direct FD fp, do not run this next chunk and do not bind_rows with 'results' - -env_ac_pefasu_no_TR = read_csv(paste0(data_dir_income_stratified_footprints, "/data/env_ac_pefasu_1_Data.csv")) %>% - filter(TIME == 2015) %>% - mutate(geo = dplyr::recode(GEO,"Austria" = "AT", - "Belgium" = "BE", - "Cyprus" = "CY", - "Czechia" = "CZ", - "Denmark" = "DK", - "Estonia" = "EE", - "Finland" = "FI", - "France" = "FR", - "Germany (until 1990 former territory of the FRG)" = "DE", - "Greece" = "EL", - "Hungary" = "HU", - "Ireland" = "IE", - "Italy" = "IT", - "Latvia" = "LV", - "Lithuania" = "LT", - "Luxembourg" = "LU", - "Malta" = "MT", - "Netherlands" = "NL", - "Norway" = "NO", - "Poland" = "PL", - "Portugal" = "PT", - "Romania" = "RO", - "Slovakia" = "SK", - "Slovenia" = "SI", - "Spain" = "ES", - "Sweden" = "SE", - "United Kingdom" = "UK", - "Bulgaria" = "BG", - "Croatia" = "HR")) %>% - select(NACE_R2,geo,Value) %>% - mutate(Value = parse_number(Value), - Value = as.numeric(Value)) %>% - spread(NACE_R2,Value) %>% - clean_names() %>% - mutate(HH_HEAT = heating_cooling_activities_by_households/total_activities_by_households, - HH_TRA = transport_activities_by_households/total_activities_by_households, - HH_OTH = other_activities_by_households/total_activities_by_households) %>% - select(geo,HH_HEAT,HH_TRA,HH_OTH) - - -env_ac_pefasu_TR = env_ac_pefasu_no_TR %>% - filter(geo == "BG") %>% - mutate(geo = dplyr::recode(geo, - "BG" = "TR")) - -env_ac_pefasu = rbind(env_ac_pefasu_no_TR,env_ac_pefasu_TR) %>% - gather(sector,share_of_total_energy,-geo) - -env_ac_ainah_r2 = read_csv(paste0(data_dir_income_stratified_footprints, "/data/env_ac_ainah_r2_1_Data.csv")) %>% - filter(TIME == 2015) %>% - mutate(geo = dplyr::recode(GEO,"Austria" = "AT", - "Belgium" = "BE", - "Cyprus" = "CY", - "Czechia" = "CZ", - "Denmark" = "DK", - "Estonia" = "EE", - "Finland" = "FI", - "France" = "FR", - "Germany (until 1990 former territory of the FRG)" = "DE", - "Greece" = "EL", - "Hungary" = "HU", - "Ireland" = "IE", - "Italy" = "IT", - "Latvia" = "LV", - "Lithuania" = "LT", - "Luxembourg" = "LU", - "Malta" = "MT", - "Netherlands" = "NL", - "Norway" = "NO", - "Poland" = "PL", - "Portugal" = "PT", - "Romania" = "RO", - "Slovakia" = "SK", - "Slovenia" = "SI", - "Spain" = "ES", - "Sweden" = "SE", - "Turkey" = "TR", - "United Kingdom" = "UK", - "Bulgaria" = "BG", - "Croatia" = "HR")) %>% - select(NACE_R2,AIRPOL,geo,Value) %>% - mutate(Value = parse_number(Value), - Value = as.numeric(Value)) %>% - spread(NACE_R2,Value) %>% - clean_names() %>% - mutate(HH_HEAT = heating_cooling_activities_by_households/total_activities_by_households, - HH_TRA = transport_activities_by_households/total_activities_by_households, - HH_OTH = other_activities_by_households/total_activities_by_households) %>% - select(geo,airpol,HH_HEAT,HH_TRA,HH_OTH) - - -env_ac_ainah_r2_co2 = env_ac_ainah_r2 %>% - filter(airpol == "Carbon dioxide") %>% - select(-airpol) %>% - gather(sector,share_of_total_co2,-geo) - -env_ac_ainah_r2_ch4 = env_ac_ainah_r2 %>% - filter(airpol == "Methane") %>% - select(-airpol) %>% - gather(sector,share_of_total_ch4,-geo) - -env_ac_ainah_r2_n2o = env_ac_ainah_r2 %>% - filter(airpol == "Nitrous oxide") %>% - select(-airpol) %>% - gather(sector,share_of_total_n2o,-geo) - -direct_FD_fp_long = national_fp %>% - filter(fd_category == "Final consumption expenditure by households", - geo %in% c("AT", - "BE", "BG", "CY", "CZ", - "DE" , "DK" , "EE" , - "ES" , "FI" , "FR" , - "UK", "EL", "HR" , - "HU" , "IE" , "IT" , - "LT" , "LU" , "LV" , - "MT" , "NL" , "PL" , - "PT" , "TR" , "SK" , - "SI" , "SE" , "RO" , - "NO")) %>% - select(year,geo,fd_category,direct_FD_co2, - direct_FD_co2_noncombustion_cement, - direct_FD_co2_noncombustion_lime, - direct_FD_co2_agriculture_peatdecay, - direct_FD_co2_waste_biogenic, - direct_FD_co2_waste_fossil, - direct_FD_ch4, - direct_FD_ch4_noncombustion_gas, - direct_FD_ch4_noncombustion_oil, - direct_FD_ch4_noncombustion_anthracite, - direct_FD_ch4_noncombustion_bituminouscoal, - direct_FD_ch4_noncombustion_cokingcoal, - direct_FD_ch4_noncombustion_lignite, - direct_FD_ch4_noncombustion_subbituminouscoal, - direct_FD_ch4_noncombustion_oilrefinery, - direct_FD_ch4_agriculture, - direct_FD_ch4_waste, - direct_FD_n2o, - direct_FD_n2o_agriculture, - direct_FD_sf6, - direct_FD_hfc, - direct_FD_pfc, - direct_FD_energy, - direct_FD_biomass, - direct_FD_const_materials, - direct_FD_ffuels, - direct_FD_ores, - direct_FD_cropland, - direct_FD_forest_land, - direct_FD_pasture_land) %>% - slice(rep(1:n(), each = 3)) - -sector = rep(c("HH_HEAT","HH_TRA","HH_OTH"), nrow(direct_FD_fp_long)/3) - -direct_FD_fp_long_disagg = cbind(sector,direct_FD_fp_long) %>% - mutate(coicop = ifelse(sector == "HH_TRA","CP072", - ifelse(sector == "HH_HEAT","CP045","CP05")), - five_sectors = ifelse(sector == "HH_TRA", "transport", - ifelse(sector == "HH_HEAT", "shelter", "manufactured goods"))) %>% - left_join(env_ac_ainah_r2_co2, by = c("geo","sector")) %>% - left_join(env_ac_ainah_r2_ch4, by = c("geo","sector")) %>% - left_join(env_ac_ainah_r2_n2o, by = c("geo","sector")) %>% - left_join(env_ac_pefasu, by = c("geo","sector")) %>% - mutate(direct_FD_co2 = (direct_FD_co2 + - direct_FD_co2_noncombustion_cement + - direct_FD_co2_noncombustion_lime + - direct_FD_co2_agriculture_peatdecay + - direct_FD_co2_waste_biogenic + - direct_FD_co2_waste_fossil)*share_of_total_co2, - direct_FD_ch4 = (direct_FD_ch4 + - direct_FD_ch4_noncombustion_gas + - direct_FD_ch4_noncombustion_oil + - direct_FD_ch4_noncombustion_anthracite + - direct_FD_ch4_noncombustion_bituminouscoal + - direct_FD_ch4_noncombustion_cokingcoal + - direct_FD_ch4_noncombustion_lignite + - direct_FD_ch4_noncombustion_subbituminouscoal + - direct_FD_ch4_noncombustion_oilrefinery + - direct_FD_ch4_agriculture + - direct_FD_ch4_waste)*share_of_total_ch4, - direct_FD_n2o = (direct_FD_n2o + - direct_FD_n2o_agriculture)*share_of_total_n2o, - direct_FD_energy = direct_FD_energy*share_of_total_energy) %>% - left_join(shares, by = c("year","geo","coicop")) %>% - mutate(disaggregated_direct_FD_co2 = direct_FD_co2*share, - disaggregated_direct_FD_ch4 = direct_FD_ch4*share, - disaggregated_direct_FD_n2o = direct_FD_n2o*share, - disaggregated_direct_FD_energy = direct_FD_energy*share) %>% - select(year,geo,sector, quintile, - coicop, five_sectors, - disaggregated_direct_FD_co2, - disaggregated_direct_FD_ch4, - disaggregated_direct_FD_n2o, - disaggregated_direct_FD_energy) - -direct_FD_co2 = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_co2) %>% - spread(quintile,disaggregated_direct_FD_co2) %>% - rename(q1_co2 = QUINTILE1, - q2_co2 = QUINTILE2, - q3_co2 = QUINTILE3, - q4_co2 = QUINTILE4, - q5_co2 = QUINTILE5) %>% - mutate(q1_co2_domestic = q1_co2, - q2_co2_domestic = q2_co2, - q3_co2_domestic = q3_co2, - q4_co2_domestic = q4_co2, - q5_co2_domestic = q5_co2, - co2_total = q1_co2+q2_co2+q3_co2+q4_co2+q5_co2, - co2_total_domestic = q1_co2_domestic+ - q2_co2_domestic+q3_co2_domestic+ - q4_co2_domestic+q5_co2_domestic) - -direct_FD_ch4 = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_ch4) %>% - spread(quintile,disaggregated_direct_FD_ch4) %>% - rename(q1_ch4 = QUINTILE1, - q2_ch4 = QUINTILE2, - q3_ch4 = QUINTILE3, - q4_ch4 = QUINTILE4, - q5_ch4 = QUINTILE5) %>% - mutate(q1_ch4_domestic = q1_ch4, - q2_ch4_domestic = q2_ch4, - q3_ch4_domestic = q3_ch4, - q4_ch4_domestic = q4_ch4, - q5_ch4_domestic = q5_ch4, - ch4_total = q1_ch4+q2_ch4+q3_ch4+q4_ch4+q5_ch4, - ch4_total_domestic = q1_ch4_domestic+ - q2_ch4_domestic+q3_ch4_domestic+ - q4_ch4_domestic+q5_ch4_domestic) - - -direct_FD_n2o = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_n2o) %>% - spread(quintile,disaggregated_direct_FD_n2o) %>% - rename(q1_n2o = QUINTILE1, - q2_n2o = QUINTILE2, - q3_n2o = QUINTILE3, - q4_n2o = QUINTILE4, - q5_n2o = QUINTILE5) %>% - mutate(q1_n2o_domestic = q1_n2o, - q2_n2o_domestic = q2_n2o, - q3_n2o_domestic = q3_n2o, - q4_n2o_domestic = q4_n2o, - q5_n2o_domestic = q5_n2o, - n2o_total = q1_n2o+q2_n2o+q3_n2o+q4_n2o+q5_n2o, - n2o_total_domestic = q1_n2o_domestic+ - q2_n2o_domestic+q3_n2o_domestic+ - q4_n2o_domestic+q5_n2o_domestic) - -direct_FD_energy = direct_FD_fp_long_disagg %>% - select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_energy) %>% - spread(quintile,disaggregated_direct_FD_energy) %>% - rename(q1_energy = QUINTILE1, - q2_energy = QUINTILE2, - q3_energy = QUINTILE3, - q4_energy = QUINTILE4, - q5_energy = QUINTILE5) %>% - mutate(q1_energy_domestic = q1_energy, - q2_energy_domestic = q2_energy, - q3_energy_domestic = q3_energy, - q4_energy_domestic = q4_energy, - q5_energy_domestic = q5_energy, - energy_total = q1_energy+q2_energy+q3_energy+q4_energy+q5_energy, - energy_total_domestic = q1_energy_domestic+ - q2_energy_domestic+q3_energy_domestic+ - q4_energy_domestic+q5_energy_domestic) - - -direct_FD_fp_wide = direct_FD_co2 %>% - left_join(direct_FD_ch4, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - left_join(direct_FD_n2o, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - left_join(direct_FD_energy, by = c("year","geo", - "sector","coicop", - "five_sectors")) %>% - mutate(country_of_production = geo) %>% - mutate(q1_co2eq = q1_co2 + q1_ch4 + q1_n2o, - q2_co2eq = q2_co2 + q2_ch4 + q2_n2o, - q3_co2eq = q3_co2 + q3_ch4 + q3_n2o, - q4_co2eq = q4_co2 + q4_ch4 + q4_n2o, - q5_co2eq = q5_co2 + q5_ch4 + q5_n2o, - co2eq_total = q1_co2eq + - q2_co2eq + q3_co2eq + - q4_co2eq + q5_co2eq, - q1_co2eq_domestic = q1_co2_domestic + q1_ch4_domestic + q1_n2o_domestic, - q2_co2eq_domestic = q2_co2_domestic + q2_ch4_domestic + q2_n2o_domestic, - q3_co2eq_domestic = q3_co2_domestic + q3_ch4_domestic + q3_n2o_domestic, - q4_co2eq_domestic = q4_co2_domestic + q4_ch4_domestic + q4_n2o_domestic, - q5_co2eq_domestic = q5_co2_domestic + q5_ch4_domestic + q5_n2o_domestic, - co2eq_total_domestic = q1_co2eq_domestic + - q2_co2eq_domestic + q3_co2eq_domestic + - q4_co2eq_domestic + q5_co2eq_domestic) %>% - select(-q1_ch4, - -q2_ch4, - -q3_ch4, - -q4_ch4, - -q5_ch4, - -ch4_total, - -q1_ch4_domestic, - -q2_ch4_domestic, - -q3_ch4_domestic, - -q4_ch4_domestic, - -q5_ch4_domestic, - -ch4_total_domestic, - -q1_n2o, - -q2_n2o, - -q3_n2o, - -q4_n2o, - -q5_n2o, - -n2o_total, - -q1_n2o_domestic, - -q2_n2o_domestic, - -q3_n2o_domestic, - -q4_n2o_domestic, - -q5_n2o_domestic, - -n2o_total_domestic) - -direct_FD_fp_wide_all = direct_FD_fp_wide %>% - clean_names() %>% - select(year,geo,coicop,q1_co2:q5_co2, - q1_co2_domestic:q5_co2_domestic, - q1_co2eq:q5_co2eq, - q1_co2eq_domestic:q5_co2eq_domestic, - q1_energy:q5_energy, - q1_energy_domestic:q5_energy_domestic) - -## extract co2 and pivot long -cols_co2 = c("q1_co2", "q2_co2", "q3_co2", "q4_co2", "q5_co2") -tmp_co2 = direct_FD_fp_wide_all %>% - select(year, geo, coicop, cols_co2) %>% - pivot_longer(cols = cols_co2, - names_to = "quintile", - values_to = "co2_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2 domestic and pivot long -cols_co2_domestic = c("q1_co2_domestic", "q2_co2_domestic", "q3_co2_domestic", "q4_co2_domestic", "q5_co2_domestic") -tmp_co2_domestic = direct_FD_fp_wide_all %>% - select(year, geo, coicop, cols_co2_domestic) %>% - pivot_longer(cols = cols_co2_domestic, - names_to = "quintile", - values_to = "co2_domestic_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2eq and pivot long -cols_co2eq = c("q1_co2eq", "q2_co2eq", "q3_co2eq", "q4_co2eq", "q5_co2eq") -tmp_co2eq = direct_FD_fp_wide_all %>% - select(year, geo, coicop, cols_co2eq) %>% - pivot_longer(cols = cols_co2eq, - names_to = "quintile", - values_to = "co2eq_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract co2eq domestic and pivot long -cols_co2eq_domestic = c("q1_co2eq_domestic", "q2_co2eq_domestic", "q3_co2eq_domestic", "q4_co2eq_domestic", "q5_co2eq_domestic") -tmp_co2eq_domestic = direct_FD_fp_wide_all %>% - select(year, geo, coicop, cols_co2eq_domestic) %>% - pivot_longer(cols = cols_co2eq_domestic, - names_to = "quintile", - values_to = "co2eq_domestic_kg") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy use and pivot long -cols_energy = c("q1_energy","q2_energy","q3_energy","q4_energy","q5_energy") -tmp_energy = direct_FD_fp_wide_all %>% - select(year, geo, coicop, cols_energy) %>% - pivot_longer(cols = cols_energy, - names_to = "quintile", - values_to = "energy_use_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -## extract energy domestic and pivot long -cols_energy_domestic = c("q1_energy_domestic","q2_energy_domestic","q3_energy_domestic","q4_energy_domestic","q5_energy_domestic") -tmp_energy_domestic = direct_FD_fp_wide_all %>% - select(year, geo, coicop, cols_energy_domestic) %>% - pivot_longer(cols = cols_energy_domestic, - names_to = "quintile", - values_to = "energy_use_domestic_TJ") %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) - -direct_FD_fp_wide_recombined = tmp_co2 %>% - left_join(tmp_co2_domestic, by=c("year", "geo", "coicop", "quint")) %>% - left_join(tmp_co2eq, by=c("year", "geo", "coicop", "quint")) %>% - left_join(tmp_co2eq_domestic, by=c("year", "geo", "coicop", "quint")) %>% - left_join(tmp_energy, by=c("year", "geo", "coicop", "quint")) %>% - left_join(tmp_energy_domestic, by=c("year", "geo", "coicop", "quint")) %>% - clean_names() %>% - mutate(year = as.numeric(year)) - - - -# something is wrong with 'bah' (don't think so anymore) - the expenditures match the german and now the -#shares match the german, but some countries are clearly wrong - with almost 100% shares in CP04, whereas some look -#relatively normal - have to figure this out - huge TIVS in the CP045 sector for those weird countries. likely some weird -#sector that has a huge TIV but not much expenditure to it so need to do a weighted average - was the case, now have done -#with weighted TIV. some eastern european countries like Bulgaria still have huge CP04 emission shares - might be correct -#if their electricity is extremely dirty - need to look at the intensities of each country individually - -results = ok %>% - filter(!(geo %in% c("EA","EA12","EA13","EA17", - "EA18","EA19","EEA28","EEA30_2007", - "EFTA","EU15","EU25", - "EU27_2007", "EU27_2020", - "EU28","XK", "RS", - "MK", "ME")), - !(quintile %in% c("TOTAL","UNK")), - !(year %in% c(1988,1994,1999))) %>% - group_by(geo,quintile,year,coicop) %>% - summarise(fd_me = sum(fd_me, na.rm = TRUE), - co2_kg = sum(co2_kg, na.rm = TRUE), - co2_domestic_kg = sum(co2_domestic_kg, na.rm = TRUE), - co2_europe_kg = sum(co2_europe_kg, na.rm = TRUE), - co2eq_kg = sum(co2eq_kg, na.rm = TRUE), - co2eq_domestic_kg = sum(co2eq_domestic_kg, na.rm = TRUE), - co2eq_europe_kg = sum(co2eq_europe_kg, na.rm = TRUE), - energy_use_TJ = sum(energy_use_TJ, na.rm = TRUE), - energy_use_domestic_TJ = sum(energy_use_domestic_TJ, na.rm = TRUE), - energy_use_europe_TJ = sum(energy_use_europe_TJ, na.rm = TRUE)) %>% - ungroup() %>% - mutate(year = as.numeric(year)) %>% - na.omit() - -results_formatted = results %>% - clean_names() %>% - mutate(quint = parse_number(quintile)) %>% - select(-quintile) %>% - filter(coicop %in% c("CP011", - "CP012", - "CP02", - "CP03", - "rent", - "CP043", - "CP044", - "CP045", - "CP05", - "CP06", - "CP071", - "CP072", - "CP073", - "CP08", - "CP09", - "CP10", - "CP11", - "CP12")) - -results_formatted_with_direct_FD_fp = bind_rows(results_formatted,direct_FD_fp_wide_recombined) - - -write.csv(results_formatted_with_direct_FD_fp, paste0(data_dir_income_stratified_footprints, "/results_formatted_method2_ixi_pps_hh_no_rent.csv"))</code></pre> </div> <div id="european-exp-deciles" class="section level1"> <h1>European exp deciles</h1> -<pre class="r"><code>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")) - - -# 1) load MRIO result file -dat_results_raw = read_rds(here("data", "results_formatted_method1_ixi_pps_hh_no_rent.rds")) %>% - ungroup() %>% - mutate(year= strtoi(year)) %>% - rename(iso2 = geo) - -# get iso3 country codes to join with hh data -country_codes = ISOcodes::ISO_3166_1 %>% - select(iso2 = Alpha_2, iso3 = Alpha_3) %>% - # resolve inconsistency between Eurostat and ISO for Greece and UK/Great Britain - mutate(iso2 = if_else(iso2=="GR", "EL", iso2)) %>% - 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")) %>% - mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %>% - rename(iso2 = geo) %>% - group_by(iso2) %>% - # impute households with next available neighbour - mutate(hh = na_locf(total_private_households)) %>% - left_join(country_codes, by="iso2") %>% - 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", - "mean_expenditure_by_quintile_long.csv"), - na = ":") %>% - #filter(year >=2010, geo != "IT") %>% - #filter(year >=2005, geo != "IT") %>% - #decide here - filter(year >=2005) %>% - mutate(imputed = if_else(is.na(mean_expenditure), TRUE, FALSE)) %>% - group_by(geo,unit,quintile) %>% - mutate(value = na_locf(mean_expenditure)) %>% - select(-mean_expenditure) %>% - ungroup() - - -# df_expenditure_2005 = df_expenditure_long %>% -# filter(year == 2010) %>% -# mutate(year = 2005, -# imputed = TRUE) -# -# df_expenditure_long = df_expenditure_long %>% -# bind_rows(df_expenditure_2005) - -## Calculate adult equivalents per household -df_adult_e_p_hh = df_expenditure_long %>% - rename(iso2 = geo) %>% - pivot_wider(id_cols = c(iso2, year, quintile, imputed), - names_from = unit, - values_from = value) %>% - clean_names() %>% - mutate(adult_e_p_hh = pps_hh/pps_ae) %>% - left_join(country_codes, by="iso2") %>% - mutate(iso3 = if_else(iso2 == "XK", "XKX", iso3), - quint = parse_number(quintile)) - - -# add quintile population data -mrio_results_with_adult_eq_all = dat_results_raw %>% - filter(year %in% c(2005, 2010, 2015)) %>% - left_join(hh_data, by=c("iso2", "year")) %>% - mutate(hh_quintile = hh/5) %>% # population per country quinitle - select(-hh) %>% - rename(hh_imputed = imputed) %>% - left_join(df_adult_e_p_hh %>% - select(iso2, year, quint, imputed_ae = imputed, adult_e_p_hh), - by=c("iso2", "year", "quint")) %>% - mutate(ae_quintile = hh_quintile * adult_e_p_hh) %>% - select(-c(hh_quintile, adult_e_p_hh)) - - -#### ONLY COUNTRIES THAT HAVE DATA FOR 2005, 2010, and 2015 -## TODO: maybe make a bit less dirty =) -complete_countries = mrio_results_with_adult_eq_all %>% - group_by(year, iso2) %>% - summarise(co2_kg = sum(co2_kg)) %>% - ungroup() %>% - filter(co2_kg>0) %>% - select(iso2, year, co2_kg) %>% - pivot_wider(id_cols = c(iso2), names_from = year, values_from = co2_kg) %>% - drop_na() %>% - select(iso2) %>% - pull() - - -hh_data %>% - filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>% -ggplot(aes(x=year, y=hh*0.000001)) + - geom_line() + - geom_point(data=hh_data %>% - filter(iso2 %in% complete_countries, - year<=2015, - year>=2005, - imputed), color="red") + - theme_ipsum() + - scale_x_continuous(labels = scales::label_number(accuracy = 1, big.mark = "")) + - labs(x="", y="Total number of households (mio)") + - facet_wrap(~iso3, scales="free_y", ncol = 4) + - theme(legend.position = "bottom", - axis.text.x = element_text(angle = 90)) - -#ggsave(here("figures", "household_size.png"), plot = p, width = 8, height = 14) - -pal <- wes_palette("Cavalcanti1", 5, type = "discrete") -pal = pal[c(1,2,5)] - -df_adult_e_p_hh %>% - filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>% - mutate(quint = parse_number(quintile)) %>% - ggplot(aes(x=quint, y=adult_e_p_hh, color=factor(year))) + - geom_line(alpha=0.5) + - theme_ipsum() + - scale_color_manual(name = "Year", values = pal) + - labs(x="", y="Adult equivivalents per household") + - facet_wrap(~iso3, ncol = 4) + - theme(legend.position = "bottom", - axis.text.x = element_text(angle = 90)) - -#ggsave(here("figures", "adult_eq_per_household.png"), plot = p, width = 8, height = 14) - -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")) - - -# calculate EU expenditure tiles based on loaded mrio result file and adult equivalents. -# returns country quintiles mapped to EU ntile rank and EU ntile boundaries -# helper function called by function below -calculate_eu_ntiles <- function(pyear, pquantile_count=10) { - - country_data_annual_sorted = summary_country_fd %>% - ungroup() %>% - filter(year==pyear) %>% - arrange(fd_pae_e) %>% - mutate(idx = 1:n(), - eu_q_rank = 0) # later to be filled with euro quintile rank - - # total EU adult equivalents (of included countries) in year - total_ae_in_year = sum(country_data_annual_sorted$ae_quintile) - - # quantile target ae population - eu_decile_adult_eq = total_ae_in_year/pquantile_count - - # country quinitles must be split to allocate ae population accorting to eu quantile target ae population - # filtering by condition that cant be fulfilled is a lazy way to create an empty dataframe - # of the same structure as country_data_annual_sorted - additional_rows = country_data_annual_sorted %>% - filter(year==1) - - # store quantile split values - eu_quantile_boundaries = data.frame(euro_q_rank = 1:pquantile_count, p = 0) - - ## can't think of a non-loop way to do this, sorry - ## loops through the ordered dataset, assignes euro quantile rank - ## and splits quintiles where necessary - eu_ae_current = 0 - euro_q_rank_current = 1 - for (row_idx in 1:nrow(country_data_annual_sorted)) { - row = country_data_annual_sorted[row_idx,] - if (row["ae_quintile"] + eu_ae_current <= eu_decile_adult_eq) { - eu_ae_current = eu_ae_current + row["ae_quintile"] - country_data_annual_sorted[row_idx, "eu_q_rank"] = euro_q_rank_current - } else { - ae_diff = eu_decile_adult_eq - eu_ae_current - ## write rest of this eu decile (split country quintile) - new_row = country_data_annual_sorted[row_idx, ] - new_row[1, "eu_q_rank"] = euro_q_rank_current - new_row[1, "ae_quintile"] = ae_diff - ## record eu quantile boundary - eu_quantile_boundaries[eu_quantile_boundaries$euro_q_rank==euro_q_rank_current, "p"] = - country_data_annual_sorted[row_idx, "fd_pae_e"] - ## put first part of population in overflow dataframe - additional_rows = additional_rows %>% - bind_rows(new_row) - ## classify rest of country quinitle population to next euro quantile - country_data_annual_sorted[row_idx, "ae_quintile"] = - country_data_annual_sorted[row_idx, "ae_quintile"] - (ae_diff+0.0001) - euro_q_rank_current = euro_q_rank_current + 1 - country_data_annual_sorted[row_idx, "eu_q_rank"] = euro_q_rank_current - eu_ae_current = country_data_annual_sorted[row_idx, "ae_quintile"] - - } - } - - country_data_eu_quantiles = country_data_annual_sorted %>% - bind_rows(additional_rows) %>% - arrange(fd_pae_e, eu_q_rank) %>% - mutate(idx = 1:n()) - - #ad zeroth and nth quantile (min and max) - eu_quantile_boundaries[pquantile_count, "p"] = max(country_data_eu_quantiles$fd_pae_e) - #tmp = data.frame(euro_q_rank = 0, p = min(country_data_eu_quantiles$fd_pae_e)) %>% - # bind_rows(eu_quantile_boundaries) - - - list("df_q_data" = country_data_eu_quantiles, "df_q_boundaries" = eu_quantile_boundaries) -} - -# maps MRIO results to EU ntile ranks, returns mapping and ntile EU boundaries -map_mrio_results_to_eu_ntiles <- function(pyear, ptarget_ntiles) { - - df_eu_ntiles = calculate_eu_ntiles(pyear, pquantile_count = ptarget_ntiles) - df_eu_ntiles_data = df_eu_ntiles$df_q_data - #df_eu_ntiles_p = df_eu_ntiles$df_q_boundaries - - sector_mapping = mrio_results_with_adult_eq %>% - group_by(sector_id) %>%# - summarise(sector_agg_id = first(sector_agg_id)) %>% - ungroup() - - df_mapped_data = mrio_results_with_adult_eq %>% - select(year, - iso2, - quint, - sector_id, - fd_me, - co2_kg, - co2_domestic_kg, - co2_europe_kg, - co2eq_kg, - co2eq_domestic_kg, - co2eq_europe_kg, - energy_use_TJ, - energy_use_domestic_TJ, - energy_use_europe_TJ, - ae_quintile) %>% - filter(year==pyear) %>% - # calc per adult aequivalent values in quintiles - mutate(fd_pae_e = fd_me*1000000/ae_quintile, - co2_pae_kg = co2_kg/ae_quintile, - co2_pae_dom_kg = co2_domestic_kg/ae_quintile, - co2_pae_eu_kg = co2_europe_kg/ae_quintile, - co2eq_pae_kg = co2eq_kg/ae_quintile, - co2eq_pae_dom_kg = co2eq_domestic_kg/ae_quintile, - co2eq_pae_eu_kg = co2eq_europe_kg/ae_quintile, - energy_use_pae_tj = energy_use_TJ/ae_quintile, - energy_use_dom_pae_tj = energy_use_domestic_TJ/ae_quintile, - energy_use_eu_pae_tj = energy_use_europe_TJ/ae_quintile) %>% - # remove totals - select(-c(fd_me, - co2_kg, - co2_domestic_kg, - co2_europe_kg, - co2eq_kg, - co2eq_domestic_kg, - co2eq_europe_kg, - energy_use_TJ, - energy_use_domestic_TJ, - energy_use_europe_TJ, - year, ae_quintile)) %>% - full_join(df_eu_ntiles_data %>% - rename(fd_pae_e_quint_tmp = fd_pae_e), by=c("iso2", "quint")) %>% - rename(adult_eq = ae_quintile) %>% # country quintile and their split fraction population - # recalc totals - mutate(fd_me = fd_pae_e*adult_eq/1000000, - co2_kg = co2_pae_kg*adult_eq, - co2_dom_kg = co2_pae_dom_kg*adult_eq, - co2_eu_kg = co2_pae_eu_kg*adult_eq, - co2eq_kg = co2eq_pae_kg*adult_eq, - co2eq_dom_kg = co2eq_pae_dom_kg*adult_eq, - co2eq_eu_kg = co2eq_pae_eu_kg*adult_eq, - energy_use_tj = energy_use_pae_tj*adult_eq, - energy_use_dom_tj = energy_use_dom_pae_tj*adult_eq, - energy_use_eu_tj = energy_use_eu_pae_tj*adult_eq - ) %>% - left_join(sector_mapping, by="sector_id") - - list("df_mapped_data" = df_mapped_data, "df_ntile_boundaries" = df_eu_ntiles$df_q_boundaries) - -} - - -### Filter only countries with complete info for years 2005, 2010, 2015 -mrio_results_with_adult_eq = mrio_results_with_adult_eq_all %>% - filter(iso2 %in% complete_countries) - -## summarize final demand per adult equvalent per quintile across all sectors as basis for eurodeciles for complete countries -summary_country_fd = mrio_results_with_adult_eq %>% - group_by(iso2, year, quint) %>% - summarise(ae_quintile = first(ae_quintile), - fd_pae_e = sum(fd_me*1000000)/(ae_quintile)) - -## summarize final demand per adult equvalent per quintile across all sectors as basis for eurodeciles for all countries -summary_country_fd_all = mrio_results_with_adult_eq_all %>% - group_by(iso2, year, quint) %>% - summarise(ae_quintile = first(ae_quintile), - fd_pae_e = sum(fd_me*1000000)/(ae_quintile)) - - -df_mapped_result_2005 = map_mrio_results_to_eu_ntiles(2005, target_eu_ntiles) -df_mapped_result_2005_data = df_mapped_result_2005$df_mapped_data -df_mapped_result_2005_ntiles = df_mapped_result_2005$df_ntile_boundaries - -df_mapped_result_2010 = map_mrio_results_to_eu_ntiles(2010, target_eu_ntiles) -df_mapped_result_2010_data = df_mapped_result_2010$df_mapped_data -df_mapped_result_2010_ntiles = df_mapped_result_2010$df_ntile_boundaries - -df_mapped_result_2015 = map_mrio_results_to_eu_ntiles(2015, target_eu_ntiles) -df_mapped_result_2015_data = df_mapped_result_2015$df_mapped_data -df_mapped_result_2015_ntiles = df_mapped_result_2015$df_ntile_boundaries - -df_mapped_result_data = df_mapped_result_2005_data %>% - bind_rows(df_mapped_result_2010_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"))) - -df_mapped_result_ntiles = - df_mapped_result_2005_ntiles %>% mutate(year=2005) %>% - bind_rows(df_mapped_result_2010_ntiles %>% mutate(year=2010)) %>% - bind_rows(df_mapped_result_2015_ntiles %>% mutate(year=2015)) - -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")) - -dat_results_raw = read_rds(here("data", "results_formatted_method1_pxp_pps_hh_no_rent.rds")) %>% - ungroup() %>% - mutate(year= strtoi(year)) %>% - rename(iso2 = geo) - -# get iso3 country codes to join with hh data -country_codes = ISOcodes::ISO_3166_1 %>% - select(iso2 = Alpha_2, iso3 = Alpha_3) %>% - # resolve inconsistency between Eurostat and ISO for Greece and UK/Great Britain - mutate(iso2 = if_else(iso2=="GR", "EL", iso2)) %>% - mutate(iso2 = if_else(iso2=="GB", "UK", iso2)) - -# 2) load Eurostat household data -hh_data = read_csv(here("data", "total_private_households.csv")) %>% - mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %>% - rename(iso2 = geo) %>% - group_by(iso2) %>% - # impute households with next available neighbour - mutate(hh = na_locf(total_private_households)) %>% - left_join(country_codes, by="iso2") %>% - 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", - "mean_expenditure_by_quintile_long.csv"), - na = ":") %>% - #filter(year >=2010, geo != "IT") %>% - #filter(year >=2005, geo != "IT") %>% - #decide here - filter(year >=2005) %>% - mutate(imputed = if_else(is.na(mean_expenditure), TRUE, FALSE)) %>% - group_by(geo,unit,quintile) %>% - mutate(value = na_locf(mean_expenditure)) %>% - select(-mean_expenditure) %>% - ungroup() - -# df_expenditure_2005 = df_expenditure_long %>% -# filter(year == 2010) %>% -# mutate(year = 2005, -# imputed = TRUE) -# -# df_expenditure_long = df_expenditure_long %>% -# bind_rows(df_expenditure_2005) - -## Calculate adult equivalents per household -df_adult_e_p_hh = df_expenditure_long %>% - rename(iso2 = geo) %>% - pivot_wider(id_cols = c(iso2, year, quintile, imputed), - names_from = unit, - values_from = value) %>% - clean_names() %>% - mutate(adult_e_p_hh = pps_hh/pps_ae) %>% - left_join(country_codes, by="iso2") %>% - mutate(iso3 = if_else(iso2 == "XK", "XKX", iso3), - quint = parse_number(quintile)) - - -# add quintile population data -mrio_results_with_adult_eq_all = dat_results_raw %>% - filter(year %in% c(2005, 2010, 2015)) %>% - left_join(hh_data, by=c("iso2", "year")) %>% - mutate(hh_quintile = hh/5) %>% # population per country quinitle - select(-hh) %>% - rename(hh_imputed = imputed) %>% - left_join(df_adult_e_p_hh %>% - select(iso2, year, quint, imputed_ae = imputed, adult_e_p_hh), - by=c("iso2", "year", "quint")) %>% - mutate(ae_quintile = hh_quintile * adult_e_p_hh) %>% - select(-c(hh_quintile, adult_e_p_hh)) - - -#### ONLY COUNTRIES THAT HAVE DATA FOR 2005, 2010, and 2015 -## TODO: maybe make a bit less dirty =) -complete_countries = mrio_results_with_adult_eq_all %>% - group_by(year, iso2) %>% - summarise(co2_kg = sum(co2_kg)) %>% - ungroup() %>% - filter(co2_kg>0) %>% - select(iso2, year, co2_kg) %>% - pivot_wider(id_cols = c(iso2), names_from = year, values_from = co2_kg) %>% - drop_na() %>% - select(iso2) %>% - pull() - -hh_data %>% - filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>% -ggplot(aes(x=year, y=hh*0.000001)) + - geom_line() + - geom_point(data=hh_data %>% - filter(iso2 %in% complete_countries, - year<=2015, - year>=2005, - imputed), color="red") + - theme_ipsum() + - scale_x_continuous(labels = scales::label_number(accuracy = 1, big.mark = "")) + - labs(x="", y="Total number of households (mio)") + - facet_wrap(~iso3, scales="free_y", ncol = 4) + - theme(legend.position = "bottom", - axis.text.x = element_text(angle = 90)) - -#ggsave(here("figures", "household_size.png"), plot = p, width = 8, height = 14) - -pal <- wes_palette("Cavalcanti1", 5, type = "discrete") -pal = pal[c(1,2,5)] - -df_adult_e_p_hh %>% - filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>% - mutate(quint = parse_number(quintile)) %>% - ggplot(aes(x=quint, y=adult_e_p_hh, color=factor(year))) + - geom_line(alpha=0.5) + - theme_ipsum() + - scale_color_manual(name = "Year", values = pal) + - labs(x="", y="Adult equivivalents per household") + - facet_wrap(~iso3, ncol = 4) + - theme(legend.position = "bottom", - axis.text.x = element_text(angle = 90)) - -#ggsave(here("figures", "adult_eq_per_household.png"), plot = p, width = 8, height = 14) - -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")) - -# calculate EU expenditure tiles based on loaded mrio result file and adult equivalents. -# returns country quintiles mapped to EU ntile rank and EU ntile boundaries -# helper function called by function below -calculate_eu_ntiles <- function(pyear, pquantile_count=10) { - - country_data_annual_sorted = summary_country_fd %>% - ungroup() %>% - filter(year==pyear) %>% - arrange(fd_pae_e) %>% - mutate(idx = 1:n(), - eu_q_rank = 0) # later to be filled with euro quintile rank - - # total EU adult equivalents (of included countries) in year - total_ae_in_year = sum(country_data_annual_sorted$ae_quintile) - - # quantile target ae population - eu_decile_adult_eq = total_ae_in_year/pquantile_count - - # country quinitles must be split to allocate ae population accorting to eu quantile target ae population - # filtering by condition that cant be fulfilled is a lazy way to create an empty dataframe - # of the same structure as country_data_annual_sorted - additional_rows = country_data_annual_sorted %>% - filter(year==1) - - # store quantile split values - eu_quantile_boundaries = data.frame(euro_q_rank = 1:pquantile_count, p = 0) - - ## can't think of a non-loop way to do this, sorry - ## loops through the ordered dataset, assignes euro quantile rank - ## and splits quintiles where necessary - eu_ae_current = 0 - euro_q_rank_current = 1 - for (row_idx in 1:nrow(country_data_annual_sorted)) { - row = country_data_annual_sorted[row_idx,] - if (row["ae_quintile"] + eu_ae_current <= eu_decile_adult_eq) { - eu_ae_current = eu_ae_current + row["ae_quintile"] - country_data_annual_sorted[row_idx, "eu_q_rank"] = euro_q_rank_current - } else { - ae_diff = eu_decile_adult_eq - eu_ae_current - ## write rest of this eu decile (split country quintile) - new_row = country_data_annual_sorted[row_idx, ] - new_row[1, "eu_q_rank"] = euro_q_rank_current - new_row[1, "ae_quintile"] = ae_diff - ## record eu quantile boundary - eu_quantile_boundaries[eu_quantile_boundaries$euro_q_rank==euro_q_rank_current, "p"] = - country_data_annual_sorted[row_idx, "fd_pae_e"] - ## put first part of population in overflow dataframe - additional_rows = additional_rows %>% - bind_rows(new_row) - ## classify rest of country quinitle population to next euro quantile - country_data_annual_sorted[row_idx, "ae_quintile"] = - country_data_annual_sorted[row_idx, "ae_quintile"] - (ae_diff+0.0001) - euro_q_rank_current = euro_q_rank_current + 1 - country_data_annual_sorted[row_idx, "eu_q_rank"] = euro_q_rank_current - eu_ae_current = country_data_annual_sorted[row_idx, "ae_quintile"] - - } - } - - country_data_eu_quantiles = country_data_annual_sorted %>% - bind_rows(additional_rows) %>% - arrange(fd_pae_e, eu_q_rank) %>% - mutate(idx = 1:n()) - - #ad zeroth and nth quantile (min and max) - eu_quantile_boundaries[pquantile_count, "p"] = max(country_data_eu_quantiles$fd_pae_e) - #tmp = data.frame(euro_q_rank = 0, p = min(country_data_eu_quantiles$fd_pae_e)) %>% - # bind_rows(eu_quantile_boundaries) - - - list("df_q_data" = country_data_eu_quantiles, "df_q_boundaries" = eu_quantile_boundaries) -} - -# maps MRIO results to EU ntile ranks, returns mapping and ntile EU boundaries -map_mrio_results_to_eu_ntiles <- function(pyear, ptarget_ntiles) { - - df_eu_ntiles = calculate_eu_ntiles(pyear, pquantile_count = ptarget_ntiles) - df_eu_ntiles_data = df_eu_ntiles$df_q_data - #df_eu_ntiles_p = df_eu_ntiles$df_q_boundaries - - sector_mapping = mrio_results_with_adult_eq %>% - group_by(sector_id) %>%# - summarise(sector_agg_id = first(sector_agg_id)) %>% - ungroup() - - df_mapped_data = mrio_results_with_adult_eq %>% - select(year, - iso2, - quint, - sector_id, - fd_me, - co2_kg, - co2_domestic_kg, - co2_europe_kg, - co2eq_kg, - co2eq_domestic_kg, - co2eq_europe_kg, - energy_use_TJ, - energy_use_domestic_TJ, - energy_use_europe_TJ, - ae_quintile) %>% - filter(year==pyear) %>% - # calc per adult aequivalent values in quintiles - mutate(fd_pae_e = fd_me*1000000/ae_quintile, - co2_pae_kg = co2_kg/ae_quintile, - co2_pae_dom_kg = co2_domestic_kg/ae_quintile, - co2_pae_eu_kg = co2_europe_kg/ae_quintile, - co2eq_pae_kg = co2eq_kg/ae_quintile, - co2eq_pae_dom_kg = co2eq_domestic_kg/ae_quintile, - co2eq_pae_eu_kg = co2eq_europe_kg/ae_quintile, - energy_use_pae_tj = energy_use_TJ/ae_quintile, - energy_use_dom_pae_tj = energy_use_domestic_TJ/ae_quintile, - energy_use_eu_pae_tj = energy_use_europe_TJ/ae_quintile) %>% - # remove totals - select(-c(fd_me, - co2_kg, - co2_domestic_kg, - co2_europe_kg, - co2eq_kg, - co2eq_domestic_kg, - co2eq_europe_kg, - energy_use_TJ, - energy_use_domestic_TJ, - energy_use_europe_TJ, - year, ae_quintile)) %>% - full_join(df_eu_ntiles_data %>% - rename(fd_pae_e_quint_tmp = fd_pae_e), by=c("iso2", "quint")) %>% - rename(adult_eq = ae_quintile) %>% # country quintile and their split fraction population - # recalc totals - mutate(fd_me = fd_pae_e*adult_eq/1000000, - co2_kg = co2_pae_kg*adult_eq, - co2_dom_kg = co2_pae_dom_kg*adult_eq, - co2_eu_kg = co2_pae_eu_kg*adult_eq, - co2eq_kg = co2eq_pae_kg*adult_eq, - co2eq_dom_kg = co2eq_pae_dom_kg*adult_eq, - co2eq_eu_kg = co2eq_pae_eu_kg*adult_eq, - energy_use_tj = energy_use_pae_tj*adult_eq, - energy_use_dom_tj = energy_use_dom_pae_tj*adult_eq, - energy_use_eu_tj = energy_use_eu_pae_tj*adult_eq - ) %>% - left_join(sector_mapping, by="sector_id") - - list("df_mapped_data" = df_mapped_data, "df_ntile_boundaries" = df_eu_ntiles$df_q_boundaries) - -} - -### Filter only countries with complete info for years 2005, 2010, 2015 -mrio_results_with_adult_eq = mrio_results_with_adult_eq_all %>% - filter(iso2 %in% complete_countries) - -## summarize final demand per adult equvalent per quintile across all sectors as basis for eurodeciles for complete countries -summary_country_fd = mrio_results_with_adult_eq %>% - group_by(iso2, year, quint) %>% - summarise(ae_quintile = first(ae_quintile), - fd_pae_e = sum(fd_me*1000000)/(ae_quintile)) - -## summarize final demand per adult equvalent per quintile across all sectors as basis for eurodeciles for all countries -summary_country_fd_all = mrio_results_with_adult_eq_all %>% - group_by(iso2, year, quint) %>% - summarise(ae_quintile = first(ae_quintile), - fd_pae_e = sum(fd_me*1000000)/(ae_quintile)) - -df_mapped_result_2005 = map_mrio_results_to_eu_ntiles(2005, target_eu_ntiles) -df_mapped_result_2005_data = df_mapped_result_2005$df_mapped_data -df_mapped_result_2005_ntiles = df_mapped_result_2005$df_ntile_boundaries - -df_mapped_result_2010 = map_mrio_results_to_eu_ntiles(2010, target_eu_ntiles) -df_mapped_result_2010_data = df_mapped_result_2010$df_mapped_data -df_mapped_result_2010_ntiles = df_mapped_result_2010$df_ntile_boundaries - -#df_mapped_result_2015 = map_mrio_results_to_eu_ntiles(2015, target_eu_ntiles) -#df_mapped_result_2015_data = df_mapped_result_2015$df_mapped_data -#df_mapped_result_2015_ntiles = df_mapped_result_2015$df_ntile_boundaries - -df_mapped_result_data = df_mapped_result_2005_data %>% - bind_rows(df_mapped_result_2010_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, "_pxp.csv"))) - -df_mapped_result_ntiles = - df_mapped_result_2005_ntiles %>% mutate(year=2005) %>% - bind_rows(df_mapped_result_2010_ntiles %>% mutate(year=2010)) #%>% - #bind_rows(df_mapped_result_2015_ntiles %>% mutate(year=2015)) - -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")) - -# 1) load MRIO result file -dat_results_raw = read_rds(here("data", "results_formatted_method2_ixi_pps_hh_no_rent.rds")) %>% - ungroup() %>% - mutate(year= strtoi(year)) %>% - rename(iso2 = geo) - -# get iso3 country codes to join with hh data -country_codes = ISOcodes::ISO_3166_1 %>% - select(iso2 = Alpha_2, iso3 = Alpha_3) %>% - # resolve inconsistency between Eurostat and ISO for Greece and UK/Great Britain - mutate(iso2 = if_else(iso2=="GR", "EL", iso2)) %>% - mutate(iso2 = if_else(iso2=="GB", "UK", iso2)) - -# 2) load Eurostat household data -hh_data = read_csv(here("data", "total_private_households.csv")) %>% - mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %>% - rename(iso2 = geo) %>% - group_by(iso2) %>% - # impute households with next available neighbour - mutate(hh = na_locf(total_private_households)) %>% - left_join(country_codes, by="iso2") %>% - 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", - "mean_expenditure_by_quintile_long.csv"), - na = ":") %>% - #filter(year >=2010, geo != "IT") %>% - #filter(year >=2005, geo != "IT") %>% - #decide here - filter(year >=2005) %>% - mutate(imputed = if_else(is.na(mean_expenditure), TRUE, FALSE)) %>% - group_by(geo,unit,quintile) %>% - mutate(value = na_locf(mean_expenditure)) %>% - select(-mean_expenditure) %>% - ungroup() - -# df_expenditure_2005 = df_expenditure_long %>% -# filter(year == 2010) %>% -# mutate(year = 2005, -# imputed = TRUE) -# -# df_expenditure_long = df_expenditure_long %>% -# bind_rows(df_expenditure_2005) - -## Calculate adult equivalents per household -df_adult_e_p_hh = df_expenditure_long %>% - rename(iso2 = geo) %>% - pivot_wider(id_cols = c(iso2, year, quintile, imputed), - names_from = unit, - values_from = value) %>% - clean_names() %>% - mutate(adult_e_p_hh = pps_hh/pps_ae) %>% - left_join(country_codes, by="iso2") %>% - mutate(iso3 = if_else(iso2 == "XK", "XKX", iso3), - quint = parse_number(quintile)) - - -# add quintile population data -mrio_results_with_adult_eq_all = dat_results_raw %>% - filter(year %in% c(2005, 2010, 2015)) %>% - left_join(hh_data, by=c("iso2", "year")) %>% - mutate(hh_quintile = hh/5) %>% # population per country quinitle - select(-hh) %>% - rename(hh_imputed = imputed) %>% - left_join(df_adult_e_p_hh %>% - select(iso2, year, quint, imputed_ae = imputed, adult_e_p_hh), - by=c("iso2", "year", "quint")) %>% - mutate(ae_quintile = hh_quintile * adult_e_p_hh) %>% - select(-c(hh_quintile, adult_e_p_hh)) - - -#### ONLY COUNTRIES THAT HAVE DATA FOR 2005, 2010, and 2015 -## TODO: maybe make a bit less dirty =) -complete_countries = mrio_results_with_adult_eq_all %>% - group_by(year, iso2) %>% - summarise(co2_kg = sum(co2_kg)) %>% - ungroup() %>% - filter(co2_kg>0) %>% - select(iso2, year, co2_kg) %>% - pivot_wider(id_cols = c(iso2), names_from = year, values_from = co2_kg) %>% - drop_na() %>% - select(iso2) %>% - pull() - -hh_data %>% - filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>% -ggplot(aes(x=year, y=hh*0.000001)) + - geom_line() + - geom_point(data=hh_data %>% - filter(iso2 %in% complete_countries, - year<=2015, - year>=2005, - imputed), color="red") + - theme_ipsum() + - scale_x_continuous(labels = scales::label_number(accuracy = 1, big.mark = "")) + - labs(x="", y="Total number of households (mio)") + - facet_wrap(~iso3, scales="free_y", ncol = 4) + - theme(legend.position = "bottom", - axis.text.x = element_text(angle = 90)) - -#ggsave(here("figures", "household_size.png"), plot = p, width = 8, height = 14) - -pal <- wes_palette("Cavalcanti1", 5, type = "discrete") -pal = pal[c(1,2,5)] - -df_adult_e_p_hh %>% - filter(iso2 %in% complete_countries, year<=2015, year>=2005) %>% - mutate(quint = parse_number(quintile)) %>% - ggplot(aes(x=quint, y=adult_e_p_hh, color=factor(year))) + - geom_line(alpha=0.5) + - theme_ipsum() + - scale_color_manual(name = "Year", values = pal) + - labs(x="", y="Adult equivivalents per household") + - facet_wrap(~iso3, ncol = 4) + - theme(legend.position = "bottom", - axis.text.x = element_text(angle = 90)) - -#ggsave(here("figures", "adult_eq_per_household.png"), plot = p, width = 8, height = 14) - -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")) - -# calculate EU expenditure tiles based on loaded mrio result file and adult equivalents. -# returns country quintiles mapped to EU ntile rank and EU ntile boundaries -# helper function called by function below -calculate_eu_ntiles <- function(pyear, pquantile_count=10) { - - country_data_annual_sorted = summary_country_fd %>% - ungroup() %>% - filter(year==pyear) %>% - arrange(fd_pae_e) %>% - mutate(idx = 1:n(), - eu_q_rank = 0) # later to be filled with euro quintile rank - - # total EU adult equivalents (of included countries) in year - total_ae_in_year = sum(country_data_annual_sorted$ae_quintile) - - # quantile target ae population - eu_decile_adult_eq = total_ae_in_year/pquantile_count - - # country quinitles must be split to allocate ae population accorting to eu quantile target ae population - # filtering by condition that cant be fulfilled is a lazy way to create an empty dataframe - # of the same structure as country_data_annual_sorted - additional_rows = country_data_annual_sorted %>% - filter(year==1) - - # store quantile split values - eu_quantile_boundaries = data.frame(euro_q_rank = 1:pquantile_count, p = 0) - - ## can't think of a non-loop way to do this, sorry - ## loops through the ordered dataset, assignes euro quantile rank - ## and splits quintiles where necessary - eu_ae_current = 0 - euro_q_rank_current = 1 - for (row_idx in 1:nrow(country_data_annual_sorted)) { - row = country_data_annual_sorted[row_idx,] - if (row["ae_quintile"] + eu_ae_current <= eu_decile_adult_eq) { - eu_ae_current = eu_ae_current + row["ae_quintile"] - country_data_annual_sorted[row_idx, "eu_q_rank"] = euro_q_rank_current - } else { - ae_diff = eu_decile_adult_eq - eu_ae_current - ## write rest of this eu decile (split country quintile) - new_row = country_data_annual_sorted[row_idx, ] - new_row[1, "eu_q_rank"] = euro_q_rank_current - new_row[1, "ae_quintile"] = ae_diff - ## record eu quantile boundary - eu_quantile_boundaries[eu_quantile_boundaries$euro_q_rank==euro_q_rank_current, "p"] = - country_data_annual_sorted[row_idx, "fd_pae_e"] - ## put first part of population in overflow dataframe - additional_rows = additional_rows %>% - bind_rows(new_row) - ## classify rest of country quinitle population to next euro quantile - country_data_annual_sorted[row_idx, "ae_quintile"] = - country_data_annual_sorted[row_idx, "ae_quintile"] - (ae_diff+0.0001) - euro_q_rank_current = euro_q_rank_current + 1 - country_data_annual_sorted[row_idx, "eu_q_rank"] = euro_q_rank_current - eu_ae_current = country_data_annual_sorted[row_idx, "ae_quintile"] - - } - } - - country_data_eu_quantiles = country_data_annual_sorted %>% - bind_rows(additional_rows) %>% - arrange(fd_pae_e, eu_q_rank) %>% - mutate(idx = 1:n()) - - #ad zeroth and nth quantile (min and max) - eu_quantile_boundaries[pquantile_count, "p"] = max(country_data_eu_quantiles$fd_pae_e) - #tmp = data.frame(euro_q_rank = 0, p = min(country_data_eu_quantiles$fd_pae_e)) %>% - # bind_rows(eu_quantile_boundaries) - - - list("df_q_data" = country_data_eu_quantiles, "df_q_boundaries" = eu_quantile_boundaries) -} - -# maps MRIO results to EU ntile ranks, returns mapping and ntile EU boundaries -map_mrio_results_to_eu_ntiles <- function(pyear, ptarget_ntiles) { - - df_eu_ntiles = calculate_eu_ntiles(pyear, pquantile_count = ptarget_ntiles) - df_eu_ntiles_data = df_eu_ntiles$df_q_data - #df_eu_ntiles_p = df_eu_ntiles$df_q_boundaries - - sector_mapping = mrio_results_with_adult_eq %>% - group_by(coicop) %>%# - summarise(coicop = first(coicop)) %>% - ungroup() - - df_mapped_data = mrio_results_with_adult_eq %>% - select(year, - iso2, - quint, - coicop, - fd_me, - co2_kg, - co2_domestic_kg, - co2_europe_kg, - co2eq_kg, - co2eq_domestic_kg, - co2eq_europe_kg, - energy_use_tj, - energy_use_domestic_tj, - energy_use_europe_tj, - ae_quintile) %>% - filter(year==pyear) %>% - # calc per adult aequivalent values in quintiles - mutate(fd_pae_e = fd_me*1000000/ae_quintile, - co2_pae_kg = co2_kg/ae_quintile, - co2_pae_dom_kg = co2_domestic_kg/ae_quintile, - co2_pae_eu_kg = co2_europe_kg/ae_quintile, - co2eq_pae_kg = co2eq_kg/ae_quintile, - co2eq_pae_dom_kg = co2eq_domestic_kg/ae_quintile, - co2eq_pae_eu_kg = co2eq_europe_kg/ae_quintile, - energy_use_pae_tj = energy_use_tj/ae_quintile, - energy_use_dom_pae_tj = energy_use_domestic_tj/ae_quintile, - energy_use_eu_pae_tj = energy_use_europe_tj/ae_quintile) %>% - # remove totals - select(-c(fd_me, - co2_kg, - co2_domestic_kg, - co2_europe_kg, - co2eq_kg, - co2eq_domestic_kg, - co2eq_europe_kg, - energy_use_tj, - energy_use_domestic_tj, - energy_use_europe_tj, - year, ae_quintile)) %>% - full_join(df_eu_ntiles_data %>% - rename(fd_pae_e_quint_tmp = fd_pae_e), by=c("iso2", "quint")) %>% - rename(adult_eq = ae_quintile) %>% # country quintile and their split fraction population - # recalc totals - mutate(fd_me = fd_pae_e*adult_eq/1000000, - co2_kg = co2_pae_kg*adult_eq, - co2_dom_kg = co2_pae_dom_kg*adult_eq, - co2_eu_kg = co2_pae_eu_kg*adult_eq, - co2eq_kg = co2eq_pae_kg*adult_eq, - co2eq_dom_kg = co2eq_pae_dom_kg*adult_eq, - co2eq_eu_kg = co2eq_pae_eu_kg*adult_eq, - energy_use_tj = energy_use_pae_tj*adult_eq, - energy_use_dom_tj = energy_use_dom_pae_tj*adult_eq, - energy_use_eu_tj = energy_use_eu_pae_tj*adult_eq - ) #%>% - #left_join(sector_mapping, by="sector_id") - - list("df_mapped_data" = df_mapped_data, "df_ntile_boundaries" = df_eu_ntiles$df_q_boundaries) - -} - -### Filter only countries with complete info for years 2005, 2010, 2015 -mrio_results_with_adult_eq = mrio_results_with_adult_eq_all %>% - filter(iso2 %in% complete_countries) - -## summarize final demand per adult equvalent per quintile across all sectors as basis for eurodeciles for complete countries -summary_country_fd = mrio_results_with_adult_eq %>% - group_by(iso2, year, quint) %>% - summarise(ae_quintile = first(ae_quintile), - fd_pae_e = sum(fd_me*1000000)/(ae_quintile)) - -## summarize final demand per adult equvalent per quintile across all sectors as basis for eurodeciles for all countries -summary_country_fd_all = mrio_results_with_adult_eq_all %>% - group_by(iso2, year, quint) %>% - summarise(ae_quintile = first(ae_quintile), - fd_pae_e = sum(fd_me*1000000)/(ae_quintile)) - -df_mapped_result_2005 = map_mrio_results_to_eu_ntiles(2005, target_eu_ntiles) -df_mapped_result_2005_data = df_mapped_result_2005$df_mapped_data -df_mapped_result_2005_ntiles = df_mapped_result_2005$df_ntile_boundaries - -df_mapped_result_2010 = map_mrio_results_to_eu_ntiles(2010, target_eu_ntiles) -df_mapped_result_2010_data = df_mapped_result_2010$df_mapped_data -df_mapped_result_2010_ntiles = df_mapped_result_2010$df_ntile_boundaries - -df_mapped_result_2015 = map_mrio_results_to_eu_ntiles(2015, target_eu_ntiles) -df_mapped_result_2015_data = df_mapped_result_2015$df_mapped_data -df_mapped_result_2015_ntiles = df_mapped_result_2015$df_ntile_boundaries - -df_mapped_result_data = df_mapped_result_2005_data %>% - bind_rows(df_mapped_result_2010_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, "_method2_ixi.csv"))) - -df_mapped_result_ntiles = - df_mapped_result_2005_ntiles %>% mutate(year=2005) %>% - bind_rows(df_mapped_result_2010_ntiles %>% mutate(year=2010)) %>% - bind_rows(df_mapped_result_2015_ntiles %>% mutate(year=2015)) - -write_csv(df_mapped_result_ntiles, - here(paste0("data/eu_ntiles_n_", target_eu_ntiles, "_method2_ixi.csv")))</code></pre> </div>