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(&quot;/&quot;,file.path(&quot;data&quot;,&quot;metab&quot;,&quot;Exiobase&quot;, fsep=.Platform$file.sep),sep=&quot;&quot;)
-
-years_exiobase_ixi = c(2005,2010,2015)
-
-for (i in years_exiobase_ixi){
-  
-year_current = i
-
-A = read.delim(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/A.txt&quot;),header = F)
-
-write.csv(A, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/A.csv&quot;))
-
-A = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/A.csv&quot;,sep = &quot;&quot;),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, &quot;/IOT_&quot;,year_current,&quot;_ixi/Y.txt&quot;),header = F)
-
-write.csv(FD, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/Y.csv&quot;))
-
-
-Exiobase_T_labels_ixi = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/Y.csv&quot;))[4:7990,1:3]
-
-write.csv(Exiobase_T_labels_ixi, paste0(data_dir_exiobase, &quot;/Exiobase_T_labels_ixi.csv&quot;))
-
-Exiobase_FD_labels_ixi = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/Y.csv&quot;))[1:3,4:346]
-
-write.csv(Exiobase_FD_labels_ixi, paste0(data_dir_exiobase, &quot;/Exiobase_FD_labels_ixi.csv&quot;))
-
-
-FD = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/Y.csv&quot;,sep=&quot;&quot;),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, &quot;/IOT_&quot;,year_current,&quot;_ixi/FD_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# total output
-total_output = L %*% rowSums(FD)
-
-write.csv(total_output, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/total_output_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# direct environmental vectors
-satellite = read.delim(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/F.txt&quot;),header = F)
-
-write.csv(satellite, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/F.csv&quot;))
-
-
-satellite = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/F.csv&quot;,sep=&quot;&quot;),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, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/satellite_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# direct environmental vectors on final demand
-
-satellite_FD = read.delim(paste0(data_dir_exiobase, &quot;/IOT_&quot;, year_current, &quot;_ixi/satellite/F_hh.txt&quot;),header = F)
-
-write.csv(satellite_FD, paste0(data_dir_exiobase, &quot;/IOT_&quot;, year_current, &quot;_ixi/satellite/F_hh.csv&quot;))
-
-
-# CO2 combustion air
-CO2_combustion_air = satellite[24,]
-#write.csv(CO2_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/co2_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-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]&lt;-0
-#write.csv(DIV_co2_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/DIV_co2_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-TIV_co2_combustion_air = as.vector(DIV_co2_combustion_air) %*% L
-
-write.csv(TIV_co2_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-  group_by(V1) %&gt;%
-  select(-X,-V2) %&gt;%
-  summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_combustion_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_noncombustion_cement_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                  group_by(V1) %&gt;%
-                                                                  select(-X,-V2) %&gt;%
-                                                                  summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_noncombustion_lime_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                  group_by(V1) %&gt;%
-                                                                  select(-X,-V2) %&gt;%
-                                                                  summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_agriculture_peatdecay_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-# 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]&lt;-0
-TIV_co2_biogenic_air = as.vector(DIV_co2_waste_biogenic_air) %*% L
-
-write.csv(TIV_co2_biogenic_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                   group_by(V1) %&gt;%
-                                                                   select(-X,-V2) %&gt;%
-                                                                   summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_biogenic_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                   group_by(V1) %&gt;%
-                                                                   select(-X,-V2) %&gt;%
-                                                                   summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_waste_fossil_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# CH4 combustion air
-CH4_combustion_air = satellite[25,]
-#write.csv(CH4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/ch4_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-CH4_combustion_air = CH4_combustion_air*28
-#write.csv(CH4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-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]&lt;-0
-#write.csv(DIV_ch4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/DIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-TIV_ch4_combustion_air = as.vector(DIV_ch4_combustion_air) %*% L
-
-write.csv(TIV_ch4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_combustion_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_gas_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_oil_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_anthracite_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_cokingcoal_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_lignite_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-## 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]&lt;-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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                             group_by(V1) %&gt;%
-                                                                             select(-X,-V2) %&gt;%
-                                                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_oilrefinery_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# 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]&lt;-0
-TIV_ch4_agriculture_air = as.vector(DIV_ch4_agriculture_air) %*% L
-
-write.csv(TIV_ch4_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                             group_by(V1) %&gt;%
-                                                                             select(-X,-V2) %&gt;%
-                                                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_agriculture_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# 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]&lt;-0
-TIV_ch4_waste_air = as.vector(DIV_ch4_waste_air) %*% L
-
-write.csv(TIV_ch4_waste_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                             group_by(V1) %&gt;%
-                                                                             select(-X,-V2) %&gt;%
-                                                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_waste_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# N2O combustion air
-N2O_combustion_air = satellite[26,]
-#write.csv(N2O_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/n2o_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-N2O_combustion_air = N2O_combustion_air*265
-#write.csv(N2O_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-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]&lt;-0
-#write.csv(DIV_n2o_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/DIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-TIV_n2o_combustion_air = as.vector(DIV_n2o_combustion_air) %*% L
-
-write.csv(TIV_n2o_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_n2o_combustion_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# 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]&lt;-0
-TIV_n2o_agriculture_air = as.vector(DIV_n2o_agriculture_air) %*% L
-
-write.csv(TIV_n2o_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                                             group_by(V1) %&gt;%
-                                                                             select(-X,-V2) %&gt;%
-                                                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_n2o_agriculture_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# SF6 air
-SF6_air = satellite[424,]
-#write.csv(SF6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/sf6_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-SF6_air = SF6_air*23500
-#write.csv(SF6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-DIV_sf6_air = SF6_air/total_output
-DIV_sf6_air[is.na(DIV_sf6_air)]=0
-DIV_sf6_air[DIV_sf6_air == Inf]&lt;-0
-#write.csv(DIV_sf6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/DIV_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-TIV_sf6_air = as.vector(DIV_sf6_air) %*% L
-
-write.csv(TIV_sf6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_sf6_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# HFC air
-HFC_air = satellite[425,]
-#write.csv(HFC_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-DIV_hfc_air = HFC_air/total_output
-DIV_hfc_air[is.na(DIV_hfc_air)]=0
-DIV_hfc_air[DIV_hfc_air == Inf]&lt;-0
-#write.csv(DIV_hfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/DIV_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-TIV_hfc_air = as.vector(DIV_hfc_air) %*% L
-
-write.csv(TIV_hfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_hfc_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# PFC air
-PFC_air = satellite[426,]
-#write.csv(PFC_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-DIV_pfc_air = PFC_air/total_output
-DIV_pfc_air[is.na(DIV_pfc_air)]=0
-DIV_pfc_air[DIV_pfc_air == Inf]&lt;-0
-#write.csv(DIV_pfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/DIV_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-TIV_pfc_air = as.vector(DIV_pfc_air) %*% L
-
-write.csv(TIV_pfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                             group_by(V1) %&gt;%
-                                             select(-X,-V2) %&gt;%
-                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_pfc_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-
-# energy carrier use
-energy_carrier_use = satellite[470,]
-write.csv(energy_carrier_use, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/satellite/energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))
-DIV_e_u = energy_carrier_use/total_output
-DIV_e_u[is.na(DIV_e_u)]=0
-DIV_e_u[DIV_e_u == Inf]&lt;-0
-TIV_e_u = as.vector(DIV_e_u) %*% L
-
-write.csv(TIV_e_u, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))
-
-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 %&gt;%
-                                             group_by(V1) %&gt;%
-                                             select(-X,-V2) %&gt;%
-                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_e_u_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))
-}
-
-
-# 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, &quot;/IOT_&quot;,year_current,&quot;_pxp/A.txt&quot;),header = F)
-
-write.csv(A, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/A.csv&quot;))
-
-A = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/A.csv&quot;,sep = &quot;&quot;),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, &quot;/IOT_&quot;,year_current,&quot;_pxp/Y.txt&quot;),header = F)
-
-write.csv(FD, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/Y.csv&quot;))
-
-
-Exiobase_T_labels_pxp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/Y.csv&quot;))[4:9803,1:3]
-
-write.csv(Exiobase_T_labels_pxp, paste0(data_dir_exiobase, &quot;/Exiobase_T_labels_pxp.csv&quot;))
-
-Exiobase_FD_labels_pxp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/Y.csv&quot;))[1:3,4:346]
-
-write.csv(Exiobase_FD_labels_pxp, paste0(data_dir_exiobase, &quot;/Exiobase_FD_labels_pxp.csv&quot;))
-
-
-FD = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/Y.csv&quot;,sep=&quot;&quot;),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, &quot;/IOT_&quot;,year_current,&quot;_pxp/FD_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# total output
-total_output = L %*% rowSums(FD)
-
-write.csv(total_output, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/total_output_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# direct environmental vectors
-satellite = read.delim(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/F.txt&quot;),header = F)
-
-write.csv(satellite, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/F.csv&quot;))
-
-
-satellite = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/F.csv&quot;,sep=&quot;&quot;),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, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/satellite_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# direct environmental vectors on final demand
-
-satellite_FD = read.delim(paste0(data_dir_exiobase, &quot;/IOT_&quot;, year_current, &quot;_pxp/satellite/F_hh.txt&quot;),header = F)
-
-write.csv(satellite_FD, paste0(data_dir_exiobase, &quot;/IOT_&quot;, year_current, &quot;_pxp/satellite/F_hh.csv&quot;))
-
-
-# CO2 combustion air
-CO2_combustion_air = satellite[24,]
-#write.csv(CO2_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/co2_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-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]&lt;-0
-#write.csv(DIV_co2_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_co2_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-TIV_co2_combustion_air = as.vector(DIV_co2_combustion_air) %*% L
-
-write.csv(TIV_co2_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-  group_by(V1) %&gt;%
-  select(-X,-V2) %&gt;%
-  summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_combustion_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CO2 non-combustion air
-## cement
-CO2_noncombustion_cement_air = satellite[93,]
-#saveRDS(CO2_noncombustion_cement_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/co2_noncombustion_cement_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_co2_noncombustion_cement_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_co2_noncombustion_cement_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_co2_noncombustion_cement_air = as.vector(DIV_co2_noncombustion_cement_air) %*% L
-
-write.csv(TIV_co2_noncombustion_cement_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_noncombustion_cement_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                  group_by(V1) %&gt;%
-                                                                  select(-X,-V2) %&gt;%
-                                                                  summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_noncombustion_cement_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## lime
-CO2_noncombustion_lime_air = satellite[94,]
-#saveRDS(CO2_noncombustion_lime_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/co2_noncombustion_lime_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_co2_noncombustion_lime_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_co2_noncombustion_lime_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_co2_noncombustion_lime_air = as.vector(DIV_co2_noncombustion_lime_air) %*% L
-
-write.csv(TIV_co2_noncombustion_lime_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_noncombustion_lime_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                group_by(V1) %&gt;%
-                                                                select(-X,-V2) %&gt;%
-                                                                summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_noncombustion_lime_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CO2 agriculture peat decay air
-CO2_agriculture_peatdecay_air = satellite[428,]
-#saveRDS(CO2_agriculture_peatdecay_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/co2_agriculture_peatdecay_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_co2_agriculture_peatdecay_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_co2_agriculture_peatdecay_air = as.vector(DIV_co2_agriculture_peatdecay_air) %*% L
-
-write.csv(TIV_co2_agriculture_peatdecay_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                   group_by(V1) %&gt;%
-                                                                   select(-X,-V2) %&gt;%
-                                                                   summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_agriculture_peatdecay_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CO2 waste air
-## biogenic
-CO2_waste_biogenic_air = satellite[438,]
-#saveRDS(CO2_waste_biogenic_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/co2_waste_biogenic_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_co2_waste_biogenic_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_co2_waste_biogenic_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_co2_biogenic_air = as.vector(DIV_co2_waste_biogenic_air) %*% L
-
-write.csv(TIV_co2_biogenic_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_biogenic_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                      group_by(V1) %&gt;%
-                                                      select(-X,-V2) %&gt;%
-                                                      summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_biogenic_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## fossil
-CO2_waste_fossil_air = satellite[439,]
-#saveRDS(CO2_waste_fossil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/co2_waste_fossil_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_co2_waste_fossil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_co2_waste_fossil_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_co2_waste_fossil_air = as.vector(DIV_co2_waste_fossil_air) %*% L
-
-write.csv(TIV_co2_waste_fossil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_waste_fossil_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                          group_by(V1) %&gt;%
-                                                          select(-X,-V2) %&gt;%
-                                                          summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_co2_waste_fossil_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CH4 combustion air
-CH4_combustion_air = satellite[25,]
-#saveRDS(CH4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_combustion_air = CH4_combustion_air*28
-#saveRDS(CH4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_combustion_air = as.vector(DIV_ch4_combustion_air) %*% L
-
-#saveRDS(TIV_ch4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-write.csv(TIV_ch4_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_combustion_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CH4 non-combustion air
-## gas
-CH4_noncombustion_gas_air = satellite[68,]
-#saveRDS(CH4_noncombustion_gas_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_gas_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_gas_air = CH4_noncombustion_gas_air*28
-#saveRDS(CH4_noncombustion_gas_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_gas_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_gas_air = as.vector(DIV_ch4_noncombustion_gas_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_gas_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_gas_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## oil
-CH4_noncombustion_oil_air = satellite[69,]
-#saveRDS(CH4_noncombustion_oil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_oil_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_oil_air = CH4_noncombustion_oil_air*28
-#saveRDS(CH4_noncombustion_oil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_oil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_oil_air = as.vector(DIV_ch4_noncombustion_oil_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_oil_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                               group_by(V1) %&gt;%
-                                                               select(-X,-V2) %&gt;%
-                                                               summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_oil_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## anthracite
-CH4_noncombustion_anthracite_air = satellite[70,]
-#saveRDS(CH4_noncombustion_anthracite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_anthracite_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_anthracite_air = CH4_noncombustion_anthracite_air*28
-#saveRDS(CH4_noncombustion_anthracite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_anthracite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_anthracite_air = as.vector(DIV_ch4_noncombustion_anthracite_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_anthracite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                      group_by(V1) %&gt;%
-                                                                      select(-X,-V2) %&gt;%
-                                                                      summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_anthracite_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## bituminous coal
-CH4_noncombustion_bituminouscoal_air = satellite[71,]
-#saveRDS(CH4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_bituminouscoal_air = CH4_noncombustion_bituminouscoal_air*28
-#saveRDS(CH4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_bituminouscoal_air = as.vector(DIV_ch4_noncombustion_bituminouscoal_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_bituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                          group_by(V1) %&gt;%
-                                                                          select(-X,-V2) %&gt;%
-                                                                          summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_bituminouscoal_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## coking coal
-CH4_noncombustion_cokingcoal_air = satellite[72,]
-#saveRDS(CH4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_cokingcoal_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_cokingcoal_air = CH4_noncombustion_cokingcoal_air*28
-#saveRDS(CH4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_cokingcoal_air = as.vector(DIV_ch4_noncombustion_cokingcoal_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_cokingcoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                      group_by(V1) %&gt;%
-                                                                      select(-X,-V2) %&gt;%
-                                                                      summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_cokingcoal_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## lignite
-CH4_noncombustion_lignite_air = satellite[73,]
-#saveRDS(CH4_noncombustion_lignite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_lignite_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_lignite_air = CH4_noncombustion_lignite_air*28
-#saveRDS(CH4_noncombustion_lignite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_lignite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_lignite_air = as.vector(DIV_ch4_noncombustion_lignite_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_lignite_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                   group_by(V1) %&gt;%
-                                                                   select(-X,-V2) %&gt;%
-                                                                   summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_lignite_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## subbituminous coal
-CH4_noncombustion_subbituminouscoal_air = satellite[74,]
-#saveRDS(CH4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_subbituminouscoal_air = CH4_noncombustion_subbituminouscoal_air*28
-#saveRDS(CH4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_subbituminouscoal_air = as.vector(DIV_ch4_noncombustion_subbituminouscoal_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_subbituminouscoal_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                             group_by(V1) %&gt;%
-                                                                             select(-X,-V2) %&gt;%
-                                                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-## oil refinery
-CH4_noncombustion_oilrefinery_air = satellite[75,]
-#saveRDS(CH4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_noncombustion_oilrefinery_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_noncombustion_oilrefinery_air = CH4_noncombustion_oilrefinery_air*28
-#saveRDS(CH4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_noncombustion_oilrefinery_air = as.vector(DIV_ch4_noncombustion_oilrefinery_air) %*% L
-
-write.csv(TIV_ch4_noncombustion_oilrefinery_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                                       group_by(V1) %&gt;%
-                                                                       select(-X,-V2) %&gt;%
-                                                                       summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_noncombustion_oilrefinery_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CH4 agriculture air
-CH4_agriculture_air = satellite[427,]
-#saveRDS(CH4_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_agriculture_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_agriculture_air = CH4_agriculture_air*28
-#saveRDS(CH4_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_agriculture_air = as.vector(DIV_ch4_agriculture_air) %*% L
-
-write.csv(TIV_ch4_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                         group_by(V1) %&gt;%
-                                                         select(-X,-V2) %&gt;%
-                                                         summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_agriculture_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# CH4 waste air
-CH4_waste_air = satellite[436,]
-#saveRDS(CH4_waste_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_waste_air_&quot;,year_current,&quot;.rds&quot;))
-CH4_waste_air = CH4_waste_air*28
-#saveRDS(CH4_waste_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/ch4_CO2eq_waste_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_ch4_waste_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_ch4_CO2eq_waste_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_ch4_waste_air = as.vector(DIV_ch4_waste_air) %*% L
-
-write.csv(TIV_ch4_waste_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                   group_by(V1) %&gt;%
-                                                   select(-X,-V2) %&gt;%
-                                                   summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_ch4_waste_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# N2O combustion air
-N2O_combustion_air = satellite[26,]
-#saveRDS(N2O_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/n2o_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-N2O_combustion_air = N2O_combustion_air*265
-#saveRDS(N2O_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/n2o_CO2eq_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_n2o_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_n2o_combustion_air = as.vector(DIV_n2o_combustion_air) %*% L
-
-#saveRDS(TIV_n2o_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;.rds&quot;))
-write.csv(TIV_n2o_combustion_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                        group_by(V1) %&gt;%
-                                                        select(-X,-V2) %&gt;%
-                                                        summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_n2o_combustion_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# N2O agriculture air
-N2O_agriculture_air = satellite[430,]
-#saveRDS(N2O_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/n2o_agriculture_air_&quot;,year_current,&quot;.rds&quot;))
-N2O_agriculture_air = N2O_agriculture_air*265
-#saveRDS(N2O_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;.rds&quot;))
-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]&lt;-0
-#saveRDS(DIV_n2o_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;.rds&quot;))
-TIV_n2o_agriculture_air = as.vector(DIV_n2o_agriculture_air) %*% L
-
-write.csv(TIV_n2o_agriculture_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                                         group_by(V1) %&gt;%
-                                                         select(-X,-V2) %&gt;%
-                                                         summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_n2o_agriculture_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# SF6 air
-SF6_air = satellite[424,]
-#write.csv(SF6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/sf6_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-SF6_air = SF6_air*23500
-#write.csv(SF6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-DIV_sf6_air = SF6_air/total_output
-DIV_sf6_air[is.na(DIV_sf6_air)]=0
-DIV_sf6_air[DIV_sf6_air == Inf]&lt;-0
-#write.csv(DIV_sf6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-TIV_sf6_air = as.vector(DIV_sf6_air) %*% L
-
-write.csv(TIV_sf6_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                             group_by(V1) %&gt;%
-                                             select(-X,-V2) %&gt;%
-                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_sf6_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# HFC air
-HFC_air = satellite[425,]
-#write.csv(HFC_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-DIV_hfc_air = HFC_air/total_output
-DIV_hfc_air[is.na(DIV_hfc_air)]=0
-DIV_hfc_air[DIV_hfc_air == Inf]&lt;-0
-#write.csv(DIV_hfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-TIV_hfc_air = as.vector(DIV_hfc_air) %*% L
-
-write.csv(TIV_hfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                             group_by(V1) %&gt;%
-                                             select(-X,-V2) %&gt;%
-                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_hfc_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# PFC air
-PFC_air = satellite[426,]
-#write.csv(PFC_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/satellite/pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-DIV_pfc_air = PFC_air/total_output
-DIV_pfc_air[is.na(DIV_pfc_air)]=0
-DIV_pfc_air[DIV_pfc_air == Inf]&lt;-0
-#write.csv(DIV_pfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/DIV_pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-TIV_pfc_air = as.vector(DIV_pfc_air) %*% L
-
-write.csv(TIV_pfc_air, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                             group_by(V1) %&gt;%
-                                             select(-X,-V2) %&gt;%
-                                             summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_pfc_air_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-
-# 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]&lt;-0
-TIV_e_u = as.vector(DIV_e_u) %*% L
-
-#saveRDS(TIV_e_u, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_energy_carrier_use_&quot;,year_current,&quot;.rds&quot;))
-write.csv(TIV_e_u, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_energy_carrier_use_&quot;,year_current,&quot;_pxp.csv&quot;))
-
-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 %&gt;%
-                                         group_by(V1) %&gt;%
-                                         select(-X,-V2) %&gt;%
-                                         summarise_all(funs(sum)))
-
-write.csv(TIV_country_breakdown_e_u_w_labels, paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_pxp.csv&quot;))
-}</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(&quot;/&quot;,file.path(&quot;data&quot;,&quot;metab&quot;,&quot;income-stratified-footprints&quot;, fsep=.Platform$file.sep),sep=&quot;&quot;)
-
-
-################################################### !!!! method 1 - PPS HH - RENT NOT MAPPED TO EXIOBASE  !!!! ###########################################
-##########################################################################################################################################################
-##########################################################################################################################################################
-
-#### IF YOU WANT THE RESULTS USING PPS PER ADULT EQUIVALENT - FILTER &#39;MEAN EXPENDITURE BY QUINTILE&#39; BELOW FOR (unit == &quot;PPS_AE&quot;) AND MAKE SURE TO UNCOMMENT 
-#### THE LINE SAVING IT AT THE END (AND COMMENT OUT THE LINE SAVING THE &#39;PPS HH&#39; VERSION) - for both ixi and pxp Exiobase versions
-
-## Eurostat Household Budget Survey
-
-# load &#39;mean expenditure by quintile&#39; data
-hbs_exp_t133 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/hbs_exp_t133.csv&quot;))
-# rename and arrange by country
-mean_expenditure_by_quintile = hbs_exp_t133 %&gt;% 
-  rename(geo = 3, quintile = &quot;quantile&quot;) %&gt;%
-  arrange(geo)
-
-# load &#39;mean expenditure by quintile and coicop&#39; data
-hbs_str_t223 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/hbs_str_t223.csv&quot;))
-# rename and arrange by country
-mean_expenditure_by_coicop_sector = hbs_str_t223 %&gt;% 
-  rename(geo = 4, quintile = &quot;quantile&quot;) %&gt;%
-  arrange(geo) 
-
-# create long data set 
-mean_expenditure_by_quintile_long = mean_expenditure_by_quintile %&gt;%
-  filter(!(quintile %in% c(&quot;UNK&quot;,&quot;TOTAL&quot;))) %&gt;%
-  filter(!(geo %in% c(&quot;EA&quot;,
-                      &quot;EA12&quot;,
-                      &quot;EA13&quot;,
-                      &quot;EA17&quot;,
-                      &quot;EA18&quot;,
-                      &quot;EA19&quot;,
-                      &quot;EEA28&quot;,
-                      &quot;EEA30_2007&quot;,
-                      &quot;EFTA&quot;,
-                      &quot;EU15&quot;,
-                      &quot;EU25&quot;,
-                      &quot;EU27_2007&quot;,
-                      &quot;EU27_2020&quot;,
-                      &quot;EU28&quot;))) %&gt;%
-  gather(year,pps,-quintile,-unit,-geo) %&gt;%
-  rename(mean_expenditure = pps)
-
-write_csv(mean_expenditure_by_quintile_long, paste0(data_dir_income_stratified_footprints, &quot;/mean_expenditure_by_quintile_long.csv&quot;))
-
-# create long data sets for both
-mean_expenditure_by_quintile_long = mean_expenditure_by_quintile %&gt;%
-  filter(unit == &quot;PPS_HH&quot;) %&gt;% # filter &#39;mean expenditure by quintile&#39; in PPS per HouseHold
-  filter(!(quintile %in% c(&quot;UNK&quot;,&quot;TOTAL&quot;))) %&gt;% # filter out unknown and total expenditure
-  select(-unit) %&gt;%
-  gather(year,pps,-quintile,-geo)
-
-mean_expenditure_by_coicop_sector_long = mean_expenditure_by_coicop_sector %&gt;% 
-  filter(!(quintile %in% c(&quot;UNK&quot;,&quot;TOTAL&quot;))) %&gt;% # filter out unknown and total expenditure
-  select(-unit) %&gt;%
-  gather(year,pm,-quintile,-coicop,-geo) %&gt;%
-  mutate(coicop = dplyr::recode(coicop, &quot;CP041&quot; = &quot;rent&quot;,        
-                                &quot;CP042&quot; = &quot;rent&quot;)) %&gt;%           
-  group_by(geo,quintile,coicop,year) %&gt;%                               
-  mutate(pm = parse_number(pm),
-         pm = as.numeric(pm)) %&gt;%
-  summarise(pm = sum(pm, na.rm = TRUE)) %&gt;%
-  ungroup() %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE1&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 92-21-14,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE2&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 108-22-12,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE3&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 124-32-11,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE4&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 133-43-10,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE5&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 162-81-11,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE1&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 412-4-78-322,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE2&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 355-5-68-265,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE3&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 325-8-64-229,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE4&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 300-9-58-204,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE5&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 249-10-46-167,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE1&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 433-3-82-340,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE2&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 376-6-70-284,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE3&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 351-9-67-251,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE4&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 326-10-61-228,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE5&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 280-9-49-195,pm)) 
-## In the code above, I collapse (sum) the two &#39;rent&#39; HBS sectors &#39;CP041&#39; and &#39;CP042&#39; to create a 
-## single &#39;rent&#39; sector so as to allocate all rent to &#39;Real-estate services&#39; in Exiobase. 
-
-
-# join the HBS expenditure tables together
-join_expenditures = mean_expenditure_by_coicop_sector_long %&gt;% 
-  left_join(mean_expenditure_by_quintile_long, by = c(&quot;geo&quot;,&quot;quintile&quot;,&quot;year&quot;)) %&gt;%
-  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, &quot;/IOT_&quot;,year_current,&quot;_ixi/FD_&quot;,year_current,&quot;_ixi.csv&quot;))[,-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, &quot;/data/Exiobase_T_labels_ixi_w_coicop_mapping_no_rent.csv&quot;)) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  
-  # hh fd with production sector labels
-  
-  hh_fd_with_production_sector_labels = cbind(Exiobase_T_labels,Eurostat_countries) %&gt;% rename(geo = V1, sector = V2)
-  
-  # assumption of same purchase structure between quintiles of domestic and foreign final demand 
-  
-  # replicate each cell of each country&#39;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 %&gt;% slice(rep(1:n(), each = 5))) 
-  
-  quintiles = data.frame(rep(c(&quot;QUINTILE1&quot;,&quot;QUINTILE2&quot;,&quot;QUINTILE3&quot;,&quot;QUINTILE4&quot;,&quot;QUINTILE5&quot;),163)) %&gt;% rename_at(1,~&quot;quintile&quot;)
-  
-  replicated = cbind(cells_repeat,quintiles) %&gt;% rename(country_of_production = geo)
-  
-  # make fd data long
-  
-  replicated_long = replicated %&gt;% 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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_combustion_air_&quot;, year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_combustion_air_&quot;, year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CO2_europe,TIV_CO2_not_europe)
-  
-  # CO2 - noncombustion - cement - air
-  
-  Exiobase_TIV_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_noncombustion_cement_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_noncombustion_lime_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_agriculture_peatdecay_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_waste_biogenic_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_waste_fossil_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_europe,TIV_CH4_not_europe)
-  
-  # CH4 - noncombustion - gas - air
-  
-  Exiobase_TIV_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_gas_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_oil_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_anthracite_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_bituminouscoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_cokingcoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_lignite_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_subbituminouscoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_oilrefinery_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_agriculture_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_agriculture_europe,TIV_CH4_agriculture_not_europe)
-  
-  # CH4 - waste - air
-  
-  Exiobase_TIV_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_waste_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_waste_europe,TIV_CH4_waste_not_europe)
-  
-  
-  # N2O - combustion - air
-  
-  Exiobase_TIV_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_N2O_domestic)
-  
-  Exiobase_TIV_europe_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_N2O_europe,TIV_N2O_not_europe)
-  
-  # N2O - agriculture - air
-  
-  Exiobase_TIV_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_N2O_agriculture_domestic)
-  
-  Exiobase_TIV_europe_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_N2O_agriculture_europe,TIV_N2O_agriculture_not_europe)
-  
-  # SF6 - air
-  
-  Exiobase_TIV_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_SF6_domestic)
-  
-  Exiobase_TIV_europe_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_SF6_europe,TIV_SF6_not_europe)
-  
-  # HFC - air
-  
-  Exiobase_TIV_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_HFC_domestic)
-  
-  Exiobase_TIV_europe_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_HFC_europe,TIV_HFC_not_europe)
-  
-  # PFC - air
-  
-  Exiobase_TIV_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_PFC_domestic)
-  
-  Exiobase_TIV_europe_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_PFC_europe,TIV_PFC_not_europe)
-  
-  # Energy use
-  
-  Exiobase_TIV_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_energy_domestic)
-  
-  Exiobase_TIV_europe_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_energy_europe,TIV_energy_not_europe)
-  
-  # biomass
-  
-  Exiobase_TIV_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_biomass_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_biomass_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_biomass_domestic)
-  
-  Exiobase_TIV_europe_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_biomass_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_biomass_europe,TIV_biomass_not_europe)
-  
-  # construction materials
-  
-  Exiobase_TIV_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_const_materials_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_const_materials_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_const_materials_domestic)
-  
-  Exiobase_TIV_europe_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_const_materials_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_const_materials_europe,TIV_const_materials_not_europe)
-  
-  # fossil fuels
-  
-  Exiobase_TIV_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ffuels_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ffuels_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_ffuels_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ffuels_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_ffuels_europe,TIV_ffuels_not_europe)
-  
-  # ores
-  
-  Exiobase_TIV_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ores_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ores_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_ores_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ores_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_ores_europe,TIV_ores_not_europe)
-  
-  # cropland
-  
-  Exiobase_TIV_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_cropland_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_cropland_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_cropland_domestic)
-  
-  Exiobase_TIV_europe_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_cropland_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_cropland_europe,TIV_cropland_not_europe)
-  
-  # forest land
-  
-  Exiobase_TIV_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_forest_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_forest_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_forest_land_domestic)
-  
-  Exiobase_TIV_europe_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_forest_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_forest_land_europe,TIV_forest_land_not_europe)
-  
-  # pasture land
-  
-  Exiobase_TIV_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_pasture_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pasture_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_pasture_land_domestic)
-  
-  Exiobase_TIV_europe_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pasture_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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)) %&gt;% 
-    rename(TIV_CO2 = &quot;t(Exiobase_TIV_co2_bp)&quot;,
-           TIV_CO2_noncombustion_cement = &quot;t(Exiobase_TIV_co2_noncombustion_cement_bp)&quot;,
-           TIV_CO2_noncombustion_lime = &quot;t(Exiobase_TIV_co2_noncombustion_lime_bp)&quot;,
-           TIV_CO2_agriculture_peatdecay = &quot;t(Exiobase_TIV_co2_agriculture_peatdecay_bp)&quot;,
-           TIV_CO2_waste_biogenic = &quot;t(Exiobase_TIV_co2_waste_biogenic_bp)&quot;,
-           TIV_CO2_waste_fossil = &quot;t(Exiobase_TIV_co2_waste_fossil_bp)&quot;,
-           TIV_CH4 = &quot;t(Exiobase_TIV_ch4_bp)&quot;,
-           TIV_CH4_noncombustion_gas = &quot;t(Exiobase_TIV_ch4_noncombustion_gas_bp)&quot;,
-           TIV_CH4_noncombustion_oil = &quot;t(Exiobase_TIV_ch4_noncombustion_oil_bp)&quot;,
-           TIV_CH4_noncombustion_anthracite = &quot;t(Exiobase_TIV_ch4_noncombustion_anthracite_bp)&quot;,
-           TIV_CH4_noncombustion_bituminouscoal = &quot;t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp)&quot;,
-           TIV_CH4_noncombustion_cokingcoal = &quot;t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp)&quot;,
-           TIV_CH4_noncombustion_lignite = &quot;t(Exiobase_TIV_ch4_noncombustion_lignite_bp)&quot;,
-           TIV_CH4_noncombustion_subbituminouscoal = &quot;t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp)&quot;,
-           TIV_CH4_noncombustion_oilrefinery = &quot;t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp)&quot;,
-           TIV_CH4_agriculture = &quot;t(Exiobase_TIV_ch4_agriculture_bp)&quot;,
-           TIV_CH4_waste = &quot;t(Exiobase_TIV_ch4_waste_bp)&quot;,
-           TIV_N2O = &quot;t(Exiobase_TIV_n2o_bp)&quot;,
-           TIV_N2O_agriculture = &quot;t(Exiobase_TIV_n2o_agriculture_bp)&quot;,
-           TIV_SF6 = &quot;t(Exiobase_TIV_sf6_bp)&quot;,
-           TIV_HFC = &quot;t(Exiobase_TIV_hfc_bp)&quot;,
-           TIV_PFC = &quot;t(Exiobase_TIV_pfc_bp)&quot;,
-           TIV_energy = &quot;t(Exiobase_TIV_energy_use_bp)&quot;,
-           TIV_biomass = &quot;t(Exiobase_TIV_biomass_bp)&quot;,
-           TIV_const_materials = &quot;t(Exiobase_TIV_const_materials_bp)&quot;,
-           TIV_ffuels = &quot;t(Exiobase_TIV_ffuels_bp)&quot;,
-           TIV_ores = &quot;t(Exiobase_TIV_ores_bp)&quot;,
-           TIV_cropland = &quot;t(Exiobase_TIV_cropland_bp)&quot;,
-           TIV_forest_land = &quot;t(Exiobase_TIV_forest_land_bp)&quot;,
-           TIV_pasture_land = &quot;t(Exiobase_TIV_pasture_land_bp)&quot;) %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  year = as.character(rep(year_current,nrow(TIV_with_labels)))
-  
-  look = cbind(year,TIV_with_labels) %&gt;% 
-    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 %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_waste_fossil_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_agriculture_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_waste_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_n2o_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_n2o_agriculture_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_sf6_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_hfc_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_pfc_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_energy_use_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_biomass_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_const_materials_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ffuels_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ores_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_cropland_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_forest_land_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_pasture_land_bp %&gt;% select(-country))  %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;),
-           country = dplyr::recode(country, &quot;GR&quot; = &quot;EL&quot;, &quot;GB&quot; = &quot;UK&quot;)) 
-  
-  year_domestic = as.character(rep(year_current,nrow(domestic_TIV_with_labels)))
-  
-  look_domestic = cbind(year_domestic,domestic_TIV_with_labels) %&gt;% 
-    rename(country_of_production = V1, sector = V2, geo = country, year = year_domestic) %&gt;%
-    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) %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  year_europe = as.character(rep(year_current,nrow(europe_TIV_with_labels)))
-  
-  look_europe = cbind(year_europe,europe_TIV_with_labels) %&gt;% 
-    rename(country_of_production = V1, sector = V2, year = year_europe) %&gt;%
-    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, &quot;/Exiobase_FD_labels_ixi.csv&quot;)))[-1,-3]) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  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))) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  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, &quot;/IOT_&quot;, year_current, &quot;_ixi/satellite/F_hh.csv&quot;, sep = &quot;&quot;),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)) %&gt;% 
-    rename(year = year_national_fp,
-           geo = V1, 
-           fd_category = V2, 
-           co2 = &quot;rowSums(t(national_CO2_footprints))&quot;,
-           co2_noncombustion_cement = &quot;rowSums(t(national_CO2_noncombustion_cement_footprints))&quot;,
-           co2_noncombustion_lime = &quot;rowSums(t(national_CO2_noncombustion_lime_footprints))&quot;,
-           co2_agriculture_peatdecay = &quot;rowSums(t(national_CO2_agriculture_peatdecay_footprints))&quot;,
-           co2_waste_biogenic = &quot;rowSums(t(national_CO2_waste_biogenic_footprints))&quot;,
-           co2_waste_fossil = &quot;rowSums(t(national_CO2_waste_fossil_footprints))&quot;,
-           ch4 = &quot;rowSums(t(national_CH4_footprints))&quot;,
-           ch4_noncombustion_gas = &quot;rowSums(t(national_CH4_noncombustion_gas_footprints))&quot;,
-           ch4_noncombustion_oil = &quot;rowSums(t(national_CH4_noncombustion_oil_footprints))&quot;,
-           ch4_noncombustion_anthracite = &quot;rowSums(t(national_CH4_noncombustion_anthracite_footprints))&quot;,
-           ch4_noncombustion_bituminouscoal = &quot;rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints))&quot;,
-           ch4_noncombustion_cokingcoal = &quot;rowSums(t(national_CH4_noncombustion_cokingcoal_footprints))&quot;,
-           ch4_noncombustion_lignite = &quot;rowSums(t(national_CH4_noncombustion_lignite_footprints))&quot;,
-           ch4_noncombustion_subbituminouscoal = &quot;rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints))&quot;,
-           ch4_noncombustion_oilrefinery = &quot;rowSums(t(national_CH4_noncombustion_oilrefinery_footprints))&quot;,
-           ch4_agriculture = &quot;rowSums(t(national_CH4_agriculture_footprints))&quot;,
-           ch4_waste = &quot;rowSums(t(national_CH4_waste_footprints))&quot;,
-           n2o = &quot;rowSums(t(national_N2O_footprints))&quot;,
-           n2o_agriculture = &quot;rowSums(t(national_N2O_agriculture_footprints))&quot;,
-           sf6 = &quot;rowSums(t(national_SF6_footprints))&quot;,
-           hfc = &quot;rowSums(t(national_HFC_footprints))&quot;,
-           pfc = &quot;rowSums(t(national_PFC_footprints))&quot;,
-           energy = &quot;rowSums(t(national_energy_footprints))&quot;,
-           biomass = &quot;rowSums(t(national_biomass_footprints))&quot;,
-           const_materials = &quot;rowSums(t(national_const_materials_footprints))&quot;,
-           ffuels = &quot;rowSums(t(national_ffuels_footprints))&quot;,
-           ores = &quot;rowSums(t(national_ores_footprints))&quot;,
-           cropland = &quot;rowSums(t(national_cropland_footprints))&quot;,
-           forest_land = &quot;rowSums(t(national_forest_land_footprints))&quot;,
-           pasture_land = &quot;rowSums(t(national_pasture_land_footprints))&quot;) %&gt;%
-    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, &quot;/IOT_&quot;, year_current, &quot;_ixi/satellite/satellite_&quot;,year_current,&quot;_ixi.csv&quot;))[,-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) %&gt;%
-    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)) %&gt;%
-    rename(year = year_territorial,
-           geo = V1,
-           sector = V2) %&gt;%
-    select(-coicop,-five_sectors)
-  
-  national_territorial = rbind(national_territorial, look_territorial)
-  
-}
-
-write.csv(national_territorial, paste0(data_dir_income_stratified_footprints, &quot;/national_territorial_ixi.csv&quot;))
-write_rds(national_territorial, paste0(data_dir_income_stratified_footprints, &quot;/national_territorial_ixi.rds&quot;))
-
-
-write.csv(national_fp, paste0(data_dir_income_stratified_footprints, &quot;/national_fp_ixi.csv&quot;))
-write_rds(national_fp, paste0(data_dir_income_stratified_footprints, &quot;/national_fp_ixi.rds&quot;))
-
-# calculate quintile shares within each sector
-shares = join_expenditures %&gt;%
-  group_by(coicop,geo,year) %&gt;%
-  mutate(share = pps_coicop/sum(pps_coicop))
-
-# pre-processing
-
-fd_exiobase = disaggregated_final_demand %&gt;% 
-  left_join(shares, by = c(&quot;year&quot;,&quot;geo&quot;,&quot;coicop&quot;,&quot;quintile&quot;)) %&gt;%
-  mutate(disaggregated_fd = value*share) %&gt;%
-  select(year,geo,quintile,country_of_production,sector,coicop,disaggregated_fd) %&gt;%
-  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 &#39;results&#39;
-
-env_ac_pefasu_no_TR = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/env_ac_pefasu_1_Data.csv&quot;)) %&gt;%
-  filter(TIME == 2015) %&gt;%
-  mutate(geo = dplyr::recode(GEO,&quot;Austria&quot; = &quot;AT&quot;, 
-                             &quot;Belgium&quot; = &quot;BE&quot;,
-                             &quot;Cyprus&quot; = &quot;CY&quot;,
-                             &quot;Czechia&quot; = &quot;CZ&quot;,
-                             &quot;Denmark&quot; = &quot;DK&quot;,
-                             &quot;Estonia&quot; = &quot;EE&quot;,
-                             &quot;Finland&quot; = &quot;FI&quot;,
-                             &quot;France&quot; = &quot;FR&quot;,
-                             &quot;Germany (until 1990 former territory of the FRG)&quot; = &quot;DE&quot;,
-                             &quot;Greece&quot; = &quot;EL&quot;,
-                             &quot;Hungary&quot; = &quot;HU&quot;,
-                             &quot;Ireland&quot; = &quot;IE&quot;,
-                             &quot;Italy&quot; = &quot;IT&quot;,
-                             &quot;Latvia&quot; = &quot;LV&quot;,
-                             &quot;Lithuania&quot; = &quot;LT&quot;,
-                             &quot;Luxembourg&quot; = &quot;LU&quot;,
-                             &quot;Malta&quot; = &quot;MT&quot;,
-                             &quot;Netherlands&quot; = &quot;NL&quot;,
-                             &quot;Norway&quot; = &quot;NO&quot;,
-                             &quot;Poland&quot; = &quot;PL&quot;,
-                             &quot;Portugal&quot; = &quot;PT&quot;,
-                             &quot;Romania&quot; = &quot;RO&quot;,
-                             &quot;Slovakia&quot; = &quot;SK&quot;,
-                             &quot;Slovenia&quot; = &quot;SI&quot;,
-                             &quot;Spain&quot; = &quot;ES&quot;,
-                             &quot;Sweden&quot; = &quot;SE&quot;,
-                             &quot;United Kingdom&quot; = &quot;UK&quot;,
-                             &quot;Bulgaria&quot; = &quot;BG&quot;,
-                             &quot;Croatia&quot; = &quot;HR&quot;)) %&gt;%
-  select(NACE_R2,geo,Value) %&gt;%
-  mutate(Value = parse_number(Value),
-         Value = as.numeric(Value)) %&gt;%
-  spread(NACE_R2,Value) %&gt;%
-  clean_names() %&gt;%
-  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) %&gt;%
-  select(geo,HH_HEAT,HH_TRA,HH_OTH) 
-
-
-env_ac_pefasu_TR = env_ac_pefasu_no_TR %&gt;%
-  filter(geo == &quot;BG&quot;) %&gt;%
-  mutate(geo = dplyr::recode(geo,
-                             &quot;BG&quot; = &quot;TR&quot;))
-
-env_ac_pefasu = rbind(env_ac_pefasu_no_TR,env_ac_pefasu_TR) %&gt;%
-  gather(sector,share_of_total_energy,-geo)
-
-env_ac_ainah_r2 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/env_ac_ainah_r2_1_Data.csv&quot;)) %&gt;%
-  filter(TIME == 2015) %&gt;%
-  mutate(geo = dplyr::recode(GEO,&quot;Austria&quot; = &quot;AT&quot;, 
-                             &quot;Belgium&quot; = &quot;BE&quot;,
-                             &quot;Cyprus&quot; = &quot;CY&quot;,
-                             &quot;Czechia&quot; = &quot;CZ&quot;,
-                             &quot;Denmark&quot; = &quot;DK&quot;,
-                             &quot;Estonia&quot; = &quot;EE&quot;,
-                             &quot;Finland&quot; = &quot;FI&quot;,
-                             &quot;France&quot; = &quot;FR&quot;,
-                             &quot;Germany (until 1990 former territory of the FRG)&quot; = &quot;DE&quot;,
-                             &quot;Greece&quot; = &quot;EL&quot;,
-                             &quot;Hungary&quot; = &quot;HU&quot;,
-                             &quot;Ireland&quot; = &quot;IE&quot;,
-                             &quot;Italy&quot; = &quot;IT&quot;,
-                             &quot;Latvia&quot; = &quot;LV&quot;,
-                             &quot;Lithuania&quot; = &quot;LT&quot;,
-                             &quot;Luxembourg&quot; = &quot;LU&quot;,
-                             &quot;Malta&quot; = &quot;MT&quot;,
-                             &quot;Netherlands&quot; = &quot;NL&quot;,
-                             &quot;Norway&quot; = &quot;NO&quot;,
-                             &quot;Poland&quot; = &quot;PL&quot;,
-                             &quot;Portugal&quot; = &quot;PT&quot;,
-                             &quot;Romania&quot; = &quot;RO&quot;,
-                             &quot;Slovakia&quot; = &quot;SK&quot;,
-                             &quot;Slovenia&quot; = &quot;SI&quot;,
-                             &quot;Spain&quot; = &quot;ES&quot;,
-                             &quot;Sweden&quot; = &quot;SE&quot;,
-                             &quot;Turkey&quot; = &quot;TR&quot;,
-                             &quot;United Kingdom&quot; = &quot;UK&quot;,
-                             &quot;Bulgaria&quot; = &quot;BG&quot;,
-                             &quot;Croatia&quot; = &quot;HR&quot;)) %&gt;%
-  select(NACE_R2,AIRPOL,geo,Value) %&gt;%
-  mutate(Value = parse_number(Value),
-         Value = as.numeric(Value)) %&gt;%
-  spread(NACE_R2,Value) %&gt;%
-  clean_names() %&gt;%
-  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) %&gt;%
-  select(geo,airpol,HH_HEAT,HH_TRA,HH_OTH) 
-
-
-env_ac_ainah_r2_co2 = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Carbon dioxide&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_co2,-geo)
-
-env_ac_ainah_r2_ch4 = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Methane&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_ch4,-geo)
-
-env_ac_ainah_r2_n2o = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Nitrous oxide&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_n2o,-geo)
-
-direct_FD_fp_long = national_fp %&gt;%
-  filter(fd_category == &quot;Final consumption expenditure by households&quot;,
-         geo %in% c(&quot;AT&quot;,
-                    &quot;BE&quot;, &quot;BG&quot;, &quot;CY&quot;, &quot;CZ&quot;,
-                    &quot;DE&quot; , &quot;DK&quot; , &quot;EE&quot; , 
-                    &quot;ES&quot; , &quot;FI&quot; , &quot;FR&quot; , 
-                    &quot;UK&quot;, &quot;EL&quot;, &quot;HR&quot; ,
-                    &quot;HU&quot; , &quot;IE&quot; , &quot;IT&quot; ,
-                    &quot;LT&quot; , &quot;LU&quot; , &quot;LV&quot; ,
-                    &quot;MT&quot; , &quot;NL&quot; , &quot;PL&quot; ,
-                    &quot;PT&quot; , &quot;TR&quot; , &quot;SK&quot; ,
-                    &quot;SI&quot; , &quot;SE&quot; , &quot;RO&quot; ,
-                    &quot;NO&quot;)) %&gt;%
-  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) %&gt;%   
-  slice(rep(1:n(), each = 3)) 
-
-sector = rep(c(&quot;HH_HEAT&quot;,&quot;HH_TRA&quot;,&quot;HH_OTH&quot;), nrow(direct_FD_fp_long)/3) 
-
-direct_FD_fp_long_disagg = cbind(sector,direct_FD_fp_long) %&gt;%
-  mutate(coicop = ifelse(sector == &quot;HH_TRA&quot;,&quot;CP072&quot;,
-                         ifelse(sector == &quot;HH_HEAT&quot;,&quot;CP045&quot;,&quot;CP05&quot;)), 
-         five_sectors = ifelse(sector == &quot;HH_TRA&quot;, &quot;transport&quot;,
-                               ifelse(sector == &quot;HH_HEAT&quot;, &quot;shelter&quot;, &quot;manufactured goods&quot;))) %&gt;%
-  left_join(env_ac_ainah_r2_co2, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_ainah_r2_ch4, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_ainah_r2_n2o, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_pefasu, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  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) %&gt;%
-  left_join(shares, by = c(&quot;year&quot;,&quot;geo&quot;,&quot;coicop&quot;)) %&gt;%
-  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) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_co2) %&gt;%
-  spread(quintile,disaggregated_direct_FD_co2) %&gt;%
-  rename(q1_co2 = QUINTILE1,
-         q2_co2 = QUINTILE2,
-         q3_co2 = QUINTILE3,
-         q4_co2 = QUINTILE4,
-         q5_co2 = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_ch4) %&gt;%
-  spread(quintile,disaggregated_direct_FD_ch4) %&gt;%
-  rename(q1_ch4 = QUINTILE1,
-         q2_ch4 = QUINTILE2,
-         q3_ch4 = QUINTILE3,
-         q4_ch4 = QUINTILE4,
-         q5_ch4 = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_n2o) %&gt;%
-  spread(quintile,disaggregated_direct_FD_n2o) %&gt;%
-  rename(q1_n2o = QUINTILE1,
-         q2_n2o = QUINTILE2,
-         q3_n2o = QUINTILE3,
-         q4_n2o = QUINTILE4,
-         q5_n2o = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_energy) %&gt;%
-  spread(quintile,disaggregated_direct_FD_energy) %&gt;%
-  rename(q1_energy = QUINTILE1,
-         q2_energy = QUINTILE2,
-         q3_energy = QUINTILE3,
-         q4_energy = QUINTILE4,
-         q5_energy = QUINTILE5) %&gt;%
-  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 %&gt;%
-  left_join(direct_FD_ch4, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                  &quot;sector&quot;,&quot;coicop&quot;,
-                                  &quot;five_sectors&quot;)) %&gt;%
-  left_join(direct_FD_n2o, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                  &quot;sector&quot;,&quot;coicop&quot;,
-                                  &quot;five_sectors&quot;)) %&gt;%
-  left_join(direct_FD_energy, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                     &quot;sector&quot;,&quot;coicop&quot;,
-                                     &quot;five_sectors&quot;)) %&gt;%
-  mutate(country_of_production = geo) %&gt;%
-  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) %&gt;%
-  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 %&gt;%
-  left_join(TIVs, by = c(&quot;year&quot;, &quot;country_of_production&quot;, &quot;coicop&quot;, &quot;sector&quot;)) %&gt;%
-  left_join(europe_TIVs, by = c(&quot;year&quot;, &quot;country_of_production&quot;, &quot;coicop&quot;, &quot;sector&quot;, &quot;five_sectors&quot;)) %&gt;%
-  left_join(domestic_TIVs, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;country_of_production&quot;, &quot;coicop&quot;, &quot;sector&quot;, &quot;five_sectors&quot;)) %&gt;%
-  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, &quot;/results_no_rent_ixi.csv&quot;))
-
-
-### create compressed results_ixi rds file
-
-#if (!require(&quot;pacman&quot;)) install.packages(&quot;pacman&quot;)
-#pacman::p_load(tidyverse,
-#               janitor,
-#               here)
-
-#dat_all = read_csv(here(&quot;data/results_ixi.csv&quot;)) %&gt;%
-#  clean_names()
-
-dat_all = results_with_direct_FD_fp %&gt;%
-  clean_names()
-
-# convert sector labels to IDs
-sectors = dat_all %&gt;%
-  distinct(sector) %&gt;%
-  mutate(sector_id = row_number())
-
-#write_csv(sectors, here(&quot;data/sector_labels.csv&quot;))
-write_csv(sectors, paste0(data_dir_income_stratified_footprints, &quot;/sectors_method1_ixi_pps_hh.csv&quot;))
-
-# convert aggregated sector labels to IDs
-sectors_agg = dat_all %&gt;%
-  distinct(five_sectors) %&gt;%
-  mutate(sector_agg_id = row_number())
-
-#write_csv(sectors_agg, here(&quot;data/sector_agg_labels.csv&quot;))
-write_csv(sectors_agg, paste0(data_dir_income_stratified_footprints, &quot;/sectors_agg_method1_ixi_pps_hh.csv&quot;))
-
-# convert COICOP labels to IDs
-coicop = dat_all %&gt;%
-  distinct(coicop) %&gt;%
-  mutate(coicop_id = row_number()) 
-
-#write_csv(sectors_agg, here(&quot;data/sector_agg_labels.csv&quot;))
-write_csv(coicop, paste0(data_dir_income_stratified_footprints, &quot;/coicop_method1_ixi_pps_hh.csv&quot;))
-
-# replace sector text labels with numerical IDs (save space)
-dat_compressed = dat_all %&gt;%
-  left_join(sectors, by=&quot;sector&quot;) %&gt;%
-  left_join(sectors_agg, by=&quot;five_sectors&quot;) %&gt;%
-  left_join(coicop, by = &quot;coicop&quot;) %&gt;%
-  select(-c(sector, five_sectors,coicop))
-
-# extract sector aggregation
-sector_mapping = dat_compressed %&gt;%
-  group_by(sector_id) %&gt;%
-  summarise(sector_agg_id = first(sector_agg_id),
-            coicop_id = first(coicop_id))
-
-# collapse country of origin
-dat_results = dat_compressed %&gt;%
-  select(-sector_agg_id,-coicop_id) %&gt;%
-  group_by(year, geo, sector_id) %&gt;%
-  summarise_if(is.numeric, sum, na.rm = TRUE)
-
-## extract final demand and pivot long
-cols_final_demand = c(&quot;quintile1&quot;, &quot;quintile2&quot;, &quot;quintile3&quot;, &quot;quintile4&quot;, &quot;quintile5&quot;)
-tmp_fd = dat_results %&gt;%
-  select(year, geo, sector_id, cols_final_demand) %&gt;%
-  pivot_longer(cols = cols_final_demand,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;fd_me&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 and pivot long
-cols_co2 = c(&quot;q1_co2&quot;, &quot;q2_co2&quot;, &quot;q3_co2&quot;, &quot;q4_co2&quot;, &quot;q5_co2&quot;)
-tmp_co2 = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2) %&gt;%
-  pivot_longer(cols = cols_co2,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 domestic and pivot long
-cols_co2_domestic = c(&quot;q1_co2_domestic&quot;, &quot;q2_co2_domestic&quot;, &quot;q3_co2_domestic&quot;, &quot;q4_co2_domestic&quot;, &quot;q5_co2_domestic&quot;)
-tmp_co2_domestic = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2_domestic) %&gt;%
-  pivot_longer(cols = cols_co2_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_domestic_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 europe and pivot long
-cols_co2_europe = c(&quot;q1_co2_europe&quot;, &quot;q2_co2_europe&quot;, &quot;q3_co2_europe&quot;, &quot;q4_co2_europe&quot;, &quot;q5_co2_europe&quot;)
-tmp_co2_europe = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2_europe) %&gt;%
-  pivot_longer(cols = cols_co2_europe,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_europe_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-
-## extract co2eq and pivot long
-cols_co2eq = c(&quot;q1_co2eq&quot;, &quot;q2_co2eq&quot;, &quot;q3_co2eq&quot;, &quot;q4_co2eq&quot;, &quot;q5_co2eq&quot;)
-tmp_co2eq = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2eq) %&gt;%
-  pivot_longer(cols = cols_co2eq,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2eq domestic and pivot long
-cols_co2eq_domestic = c(&quot;q1_co2eq_domestic&quot;, &quot;q2_co2eq_domestic&quot;, &quot;q3_co2eq_domestic&quot;, &quot;q4_co2eq_domestic&quot;, &quot;q5_co2eq_domestic&quot;)
-tmp_co2eq_domestic = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2eq_domestic) %&gt;%
-  pivot_longer(cols = cols_co2eq_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_domestic_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2eq europe and pivot long
-cols_co2eq_europe = c(&quot;q1_co2eq_europe&quot;, &quot;q2_co2eq_europe&quot;, &quot;q3_co2eq_europe&quot;, &quot;q4_co2eq_europe&quot;, &quot;q5_co2eq_europe&quot;)
-tmp_co2eq_europe = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2eq_europe) %&gt;%
-  pivot_longer(cols = cols_co2eq_europe,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_europe_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy use and pivot long
-cols_energy = c(&quot;q1_energy&quot;,&quot;q2_energy&quot;,&quot;q3_energy&quot;,&quot;q4_energy&quot;,&quot;q5_energy&quot;)
-tmp_energy = dat_results %&gt;%
-  select(year, geo, sector_id, cols_energy) %&gt;%
-  pivot_longer(cols = cols_energy,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy domestic and pivot long
-cols_energy_domestic = c(&quot;q1_energy_domestic&quot;,&quot;q2_energy_domestic&quot;,&quot;q3_energy_domestic&quot;,&quot;q4_energy_domestic&quot;,&quot;q5_energy_domestic&quot;)
-tmp_energy_domestic = dat_results %&gt;%
-  select(year, geo, sector_id, cols_energy_domestic) %&gt;%
-  pivot_longer(cols = cols_energy_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_domestic_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy europe and pivot long
-cols_energy_europe = c(&quot;q1_energy_europe&quot;,&quot;q2_energy_europe&quot;,&quot;q3_energy_europe&quot;,&quot;q4_energy_europe&quot;,&quot;q5_energy_europe&quot;)
-tmp_energy_europe = dat_results %&gt;%
-  select(year, geo, sector_id, cols_energy_europe) %&gt;%
-  pivot_longer(cols = cols_energy_europe,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_europe_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-### TODO: also convert to other indicators to this format (as blocks above)
-### TODO: left join all indicators back to &quot;results_formated&quot; like her with co2
-results_recombined = tmp_fd %&gt;%
-  left_join(tmp_co2, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2_europe, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq_europe, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy_europe, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;))
-
-
-
-# finally re-join aggregated sector IDs
-results_formatted = results_recombined %&gt;% 
-  left_join(sector_mapping, by=&quot;sector_id&quot;) %&gt;%
-  ungroup() %&gt;%
-  select(-coicop_id)
-
-#write_rds(results_formated, here(&quot;/results_formated.rds&quot;))
-
-write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_ixi_pps_hh_no_rent.csv&quot;))
-
-write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_ixi_pps_hh_no_rent.rds&quot;))
-
-
-#write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_ixi_pps_ae.csv&quot;))
-#write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_ixi_pps_ae.rds&quot;))
-
-
-################################################### !!!! 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, &quot;/IOT_&quot;,year_current,&quot;_pxp/FD_&quot;,year_current,&quot;_pxp.csv&quot;))[,-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, &quot;/data/Exiobase_T_labels_pxp_w_coicop_mapping_no_rent.csv&quot;)) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  
-  # hh fd with production sector labels
-  
-  hh_fd_with_production_sector_labels = cbind(Exiobase_T_labels,Eurostat_countries) %&gt;% rename(geo = V1, sector = V2)
-  
-  # assumption of same purchase structure between quintiles of domestic and foreign final demand 
-  
-  # replicate each cell of each country&#39;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 %&gt;% slice(rep(1:n(), each = 5))) 
-  
-  quintiles = data.frame(rep(c(&quot;QUINTILE1&quot;,&quot;QUINTILE2&quot;,&quot;QUINTILE3&quot;,&quot;QUINTILE4&quot;,&quot;QUINTILE5&quot;),200)) %&gt;% rename_at(1,~&quot;quintile&quot;)
-  
-  replicated = cbind(cells_repeat,quintiles) %&gt;% rename(country_of_production = geo)
-  
-  # make fd data long
-  
-  replicated_long = replicated %&gt;% 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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_combustion_air_&quot;, year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_combustion_air_&quot;, year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CO2_europe,TIV_CO2_not_europe)
-  
-  # CO2 - noncombustion - cement - air
-  
-  Exiobase_TIV_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_noncombustion_cement_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_noncombustion_cement_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_noncombustion_lime_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_noncombustion_lime_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_agriculture_peatdecay_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_biogenic_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_waste_biogenic_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_co2_waste_fossil_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_waste_fossil_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_europe,TIV_CH4_not_europe)
-  
-  # CH4 - noncombustion - gas - air
-  
-  Exiobase_TIV_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_gas_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_oil_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_anthracite_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_bituminouscoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_cokingcoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_lignite_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_subbituminouscoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_oilrefinery_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_agriculture_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_agriculture_europe,TIV_CH4_agriculture_not_europe)
-  
-  # CH4 - waste - air
-  
-  Exiobase_TIV_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_waste_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;, year_current, &quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_waste_europe,TIV_CH4_waste_not_europe)
-  
-  
-  
-  # N2O - combustion - air
-  
-  Exiobase_TIV_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_N2O_domestic)
-  
-  Exiobase_TIV_europe_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_N2O_europe,TIV_N2O_not_europe)
-  
-  # N2O - agriculture - air
-  
-  Exiobase_TIV_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_N2O_agriculture_domestic)
-  
-  Exiobase_TIV_europe_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_N2O_agriculture_europe,TIV_N2O_agriculture_not_europe)
-  
-  # SF6 - air
-  
-  Exiobase_TIV_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_SF6_domestic)
-  
-  Exiobase_TIV_europe_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_SF6_europe,TIV_SF6_not_europe)
-  
-  # HFC - air
-  
-  Exiobase_TIV_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_HFC_domestic)
-  
-  Exiobase_TIV_europe_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_HFC_europe,TIV_HFC_not_europe)
-  
-  # PFC - air
-  
-  Exiobase_TIV_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_PFC_domestic)
-  
-  Exiobase_TIV_europe_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_PFC_europe,TIV_PFC_not_europe)
-  
-  # Energy use
-  
-  Exiobase_TIV_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_energy_carrier_use_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_energy_domestic)
-  
-  Exiobase_TIV_europe_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_energy_europe,TIV_energy_not_europe)
-  
-  # biomass
-  
-  Exiobase_TIV_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_biomass_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_biomass_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_biomass_domestic)
-  
-  Exiobase_TIV_europe_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_biomass_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_biomass_europe,TIV_biomass_not_europe)
-  
-  # construction materials
-  
-  Exiobase_TIV_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_const_materials_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_const_materials_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_const_materials_domestic)
-  
-  Exiobase_TIV_europe_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_const_materials_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_const_materials_europe,TIV_const_materials_not_europe)
-  
-  # fossil fuels
-  
-  Exiobase_TIV_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ffuels_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ffuels_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_ffuels_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ffuels_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_ffuels_europe,TIV_ffuels_not_europe)
-  
-  # ores
-  
-  Exiobase_TIV_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_ores_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ores_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_ores_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_ores_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_ores_europe,TIV_ores_not_europe)
-  
-  # cropland
-  
-  Exiobase_TIV_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_cropland_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_cropland_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_cropland_domestic)
-  
-  Exiobase_TIV_europe_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_cropland_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_cropland_europe,TIV_cropland_not_europe)
-  
-  # forest land
-  
-  Exiobase_TIV_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_forest_land_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_forest_land_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_forest_land_domestic)
-  
-  Exiobase_TIV_europe_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_forest_land_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_forest_land_europe,TIV_forest_land_not_europe)
-  
-  # pasture land
-  
-  Exiobase_TIV_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_pasture_land_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_pasture_land_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_pasture_land_domestic)
-  
-  Exiobase_TIV_europe_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_pxp/TIV_country_breakdown_pasture_land_&quot;,year_current,&quot;_pxp.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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)) %&gt;% 
-    rename(TIV_CO2 = &quot;t(Exiobase_TIV_co2_bp)&quot;,
-           TIV_CO2_noncombustion_cement = &quot;t(Exiobase_TIV_co2_noncombustion_cement_bp)&quot;,
-           TIV_CO2_noncombustion_lime = &quot;t(Exiobase_TIV_co2_noncombustion_lime_bp)&quot;,
-           TIV_CO2_agriculture_peatdecay = &quot;t(Exiobase_TIV_co2_agriculture_peatdecay_bp)&quot;,
-           TIV_CO2_waste_biogenic = &quot;t(Exiobase_TIV_co2_waste_biogenic_bp)&quot;,
-           TIV_CO2_waste_fossil = &quot;t(Exiobase_TIV_co2_waste_fossil_bp)&quot;,
-           TIV_CH4 = &quot;t(Exiobase_TIV_ch4_bp)&quot;,
-           TIV_CH4_noncombustion_gas = &quot;t(Exiobase_TIV_ch4_noncombustion_gas_bp)&quot;,
-           TIV_CH4_noncombustion_oil = &quot;t(Exiobase_TIV_ch4_noncombustion_oil_bp)&quot;,
-           TIV_CH4_noncombustion_anthracite = &quot;t(Exiobase_TIV_ch4_noncombustion_anthracite_bp)&quot;,
-           TIV_CH4_noncombustion_bituminouscoal = &quot;t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp)&quot;,
-           TIV_CH4_noncombustion_cokingcoal = &quot;t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp)&quot;,
-           TIV_CH4_noncombustion_lignite = &quot;t(Exiobase_TIV_ch4_noncombustion_lignite_bp)&quot;,
-           TIV_CH4_noncombustion_subbituminouscoal = &quot;t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp)&quot;,
-           TIV_CH4_noncombustion_oilrefinery = &quot;t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp)&quot;,
-           TIV_CH4_agriculture = &quot;t(Exiobase_TIV_ch4_agriculture_bp)&quot;,
-           TIV_CH4_waste = &quot;t(Exiobase_TIV_ch4_waste_bp)&quot;,
-           TIV_N2O = &quot;t(Exiobase_TIV_n2o_bp)&quot;,
-           TIV_N2O_agriculture = &quot;t(Exiobase_TIV_n2o_agriculture_bp)&quot;,
-           TIV_SF6 = &quot;t(Exiobase_TIV_sf6_bp)&quot;,
-           TIV_HFC = &quot;t(Exiobase_TIV_hfc_bp)&quot;,
-           TIV_PFC = &quot;t(Exiobase_TIV_pfc_bp)&quot;,
-           TIV_energy = &quot;t(Exiobase_TIV_energy_use_bp)&quot;,
-           TIV_biomass = &quot;t(Exiobase_TIV_biomass_bp)&quot;,
-           TIV_const_materials = &quot;t(Exiobase_TIV_const_materials_bp)&quot;,
-           TIV_ffuels = &quot;t(Exiobase_TIV_ffuels_bp)&quot;,
-           TIV_ores = &quot;t(Exiobase_TIV_ores_bp)&quot;,
-           TIV_cropland = &quot;t(Exiobase_TIV_cropland_bp)&quot;,
-           TIV_forest_land = &quot;t(Exiobase_TIV_forest_land_bp)&quot;,
-           TIV_pasture_land = &quot;t(Exiobase_TIV_pasture_land_bp)&quot;) %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;))  
-  
-  year = as.character(rep(year_current,nrow(TIV_with_labels)))
-  
-  look = cbind(year,TIV_with_labels) %&gt;% 
-    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 %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_waste_fossil_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_agriculture_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_waste_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_n2o_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_n2o_agriculture_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_sf6_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_hfc_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_pfc_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_energy_use_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_biomass_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_const_materials_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ffuels_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ores_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_cropland_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_forest_land_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_pasture_land_bp %&gt;% select(-country))  %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;),
-           country = dplyr::recode(country, &quot;GR&quot; = &quot;EL&quot;, &quot;GB&quot; = &quot;UK&quot;))
-  
-  year_domestic = as.character(rep(year_current,nrow(domestic_TIV_with_labels)))
-  
-  look_domestic = cbind(year_domestic,domestic_TIV_with_labels) %&gt;% 
-    rename(country_of_production = V1, sector = V2, geo = country, year = year_domestic) %&gt;%
-    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) %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  year_europe = as.character(rep(year_current,nrow(europe_TIV_with_labels)))
-  
-  look_europe = cbind(year_europe,europe_TIV_with_labels) %&gt;% 
-    rename(country_of_production = V1, sector = V2, year = year_europe) %&gt;%
-    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, &quot;/Exiobase_FD_labels_pxp.csv&quot;)))[-1,-3]) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  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))) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  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, &quot;/IOT_&quot;, year_current, &quot;_pxp/satellite/F_hh.csv&quot;, sep = &quot;&quot;),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)) %&gt;% 
-    rename(year = year_national_fp,
-           geo = V1, 
-           fd_category = V2, 
-           co2 = &quot;rowSums(t(national_CO2_footprints))&quot;,
-           co2_noncombustion_cement = &quot;rowSums(t(national_CO2_noncombustion_cement_footprints))&quot;,
-           co2_noncombustion_lime = &quot;rowSums(t(national_CO2_noncombustion_lime_footprints))&quot;,
-           co2_agriculture_peatdecay = &quot;rowSums(t(national_CO2_agriculture_peatdecay_footprints))&quot;,
-           co2_waste_biogenic = &quot;rowSums(t(national_CO2_waste_biogenic_footprints))&quot;,
-           co2_waste_fossil = &quot;rowSums(t(national_CO2_waste_fossil_footprints))&quot;,
-           ch4 = &quot;rowSums(t(national_CH4_footprints))&quot;,
-           ch4_noncombustion_gas = &quot;rowSums(t(national_CH4_noncombustion_gas_footprints))&quot;,
-           ch4_noncombustion_oil = &quot;rowSums(t(national_CH4_noncombustion_oil_footprints))&quot;,
-           ch4_noncombustion_anthracite = &quot;rowSums(t(national_CH4_noncombustion_anthracite_footprints))&quot;,
-           ch4_noncombustion_bituminouscoal = &quot;rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints))&quot;,
-           ch4_noncombustion_cokingcoal = &quot;rowSums(t(national_CH4_noncombustion_cokingcoal_footprints))&quot;,
-           ch4_noncombustion_lignite = &quot;rowSums(t(national_CH4_noncombustion_lignite_footprints))&quot;,
-           ch4_noncombustion_subbituminouscoal = &quot;rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints))&quot;,
-           ch4_noncombustion_oilrefinery = &quot;rowSums(t(national_CH4_noncombustion_oilrefinery_footprints))&quot;,
-           ch4_agriculture = &quot;rowSums(t(national_CH4_agriculture_footprints))&quot;,
-           ch4_waste = &quot;rowSums(t(national_CH4_waste_footprints))&quot;,
-           n2o = &quot;rowSums(t(national_N2O_footprints))&quot;,
-           n2o_agriculture = &quot;rowSums(t(national_N2O_agriculture_footprints))&quot;,
-           sf6 = &quot;rowSums(t(national_SF6_footprints))&quot;,
-           hfc = &quot;rowSums(t(national_HFC_footprints))&quot;,
-           pfc = &quot;rowSums(t(national_PFC_footprints))&quot;,
-           energy = &quot;rowSums(t(national_energy_footprints))&quot;,
-           biomass = &quot;rowSums(t(national_biomass_footprints))&quot;,
-           const_materials = &quot;rowSums(t(national_const_materials_footprints))&quot;,
-           ffuels = &quot;rowSums(t(national_ffuels_footprints))&quot;,
-           ores = &quot;rowSums(t(national_ores_footprints))&quot;,
-           cropland = &quot;rowSums(t(national_cropland_footprints))&quot;,
-           forest_land = &quot;rowSums(t(national_forest_land_footprints))&quot;,
-           pasture_land = &quot;rowSums(t(national_pasture_land_footprints))&quot;) %&gt;%
-    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, &quot;/IOT_&quot;, year_current, &quot;_pxp/satellite/satellite_&quot;,year_current,&quot;_pxp.csv&quot;))[,-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) %&gt;%
-    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)) %&gt;%
-    rename(year = year_territorial,
-           geo = V1,
-           sector = V2) %&gt;%
-    select(-coicop,-five_sectors)
-  
-  national_territorial = rbind(national_territorial, look_territorial)
-  
-  
-}
-
-write.csv(national_territorial, paste0(data_dir_income_stratified_footprints, &quot;/national_territorial_pxp.csv&quot;))
-write_rds(national_territorial, paste0(data_dir_income_stratified_footprints, &quot;/national_territorial_pxp.rds&quot;))
-
-
-write.csv(national_fp, paste0(data_dir_income_stratified_footprints, &quot;/national_fp_pxp.csv&quot;))
-write_rds(national_fp, paste0(data_dir_income_stratified_footprints, &quot;/national_fp_pxp.rds&quot;))
-
-# calculate quintile shares within each sector
-shares = join_expenditures %&gt;%
-  group_by(coicop,geo,year) %&gt;%
-  mutate(share = pps_coicop/sum(pps_coicop))
-
-# pre-processing
-
-fd_exiobase = disaggregated_final_demand %&gt;% 
-  left_join(shares, by = c(&quot;year&quot;,&quot;geo&quot;,&quot;coicop&quot;,&quot;quintile&quot;)) %&gt;%
-  mutate(disaggregated_fd = value*share) %&gt;%
-  select(year,geo,quintile,country_of_production,sector,coicop,disaggregated_fd) %&gt;%
-  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 &#39;results&#39;
-
-env_ac_pefasu_no_TR = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/env_ac_pefasu_1_Data.csv&quot;)) %&gt;%
-  filter(TIME == 2015) %&gt;%
-  mutate(geo = dplyr::recode(GEO,&quot;Austria&quot; = &quot;AT&quot;, 
-                             &quot;Belgium&quot; = &quot;BE&quot;,
-                             &quot;Cyprus&quot; = &quot;CY&quot;,
-                             &quot;Czechia&quot; = &quot;CZ&quot;,
-                             &quot;Denmark&quot; = &quot;DK&quot;,
-                             &quot;Estonia&quot; = &quot;EE&quot;,
-                             &quot;Finland&quot; = &quot;FI&quot;,
-                             &quot;France&quot; = &quot;FR&quot;,
-                             &quot;Germany (until 1990 former territory of the FRG)&quot; = &quot;DE&quot;,
-                             &quot;Greece&quot; = &quot;EL&quot;,
-                             &quot;Hungary&quot; = &quot;HU&quot;,
-                             &quot;Ireland&quot; = &quot;IE&quot;,
-                             &quot;Italy&quot; = &quot;IT&quot;,
-                             &quot;Latvia&quot; = &quot;LV&quot;,
-                             &quot;Lithuania&quot; = &quot;LT&quot;,
-                             &quot;Luxembourg&quot; = &quot;LU&quot;,
-                             &quot;Malta&quot; = &quot;MT&quot;,
-                             &quot;Netherlands&quot; = &quot;NL&quot;,
-                             &quot;Norway&quot; = &quot;NO&quot;,
-                             &quot;Poland&quot; = &quot;PL&quot;,
-                             &quot;Portugal&quot; = &quot;PT&quot;,
-                             &quot;Romania&quot; = &quot;RO&quot;,
-                             &quot;Slovakia&quot; = &quot;SK&quot;,
-                             &quot;Slovenia&quot; = &quot;SI&quot;,
-                             &quot;Spain&quot; = &quot;ES&quot;,
-                             &quot;Sweden&quot; = &quot;SE&quot;,
-                             &quot;United Kingdom&quot; = &quot;UK&quot;,
-                             &quot;Bulgaria&quot; = &quot;BG&quot;,
-                             &quot;Croatia&quot; = &quot;HR&quot;)) %&gt;%
-  select(NACE_R2,geo,Value) %&gt;%
-  mutate(Value = parse_number(Value),
-         Value = as.numeric(Value)) %&gt;%
-  spread(NACE_R2,Value) %&gt;%
-  clean_names() %&gt;%
-  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) %&gt;%
-  select(geo,HH_HEAT,HH_TRA,HH_OTH) 
-
-
-env_ac_pefasu_TR = env_ac_pefasu_no_TR %&gt;%
-  filter(geo == &quot;BG&quot;) %&gt;%
-  mutate(geo = dplyr::recode(geo,
-                             &quot;BG&quot; = &quot;TR&quot;))
-
-env_ac_pefasu = rbind(env_ac_pefasu_no_TR,env_ac_pefasu_TR) %&gt;%
-  gather(sector,share_of_total_energy,-geo)
-
-env_ac_ainah_r2 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/env_ac_ainah_r2_1_Data.csv&quot;)) %&gt;%
-  filter(TIME == 2015) %&gt;%
-  mutate(geo = dplyr::recode(GEO,&quot;Austria&quot; = &quot;AT&quot;, 
-                             &quot;Belgium&quot; = &quot;BE&quot;,
-                             &quot;Cyprus&quot; = &quot;CY&quot;,
-                             &quot;Czechia&quot; = &quot;CZ&quot;,
-                             &quot;Denmark&quot; = &quot;DK&quot;,
-                             &quot;Estonia&quot; = &quot;EE&quot;,
-                             &quot;Finland&quot; = &quot;FI&quot;,
-                             &quot;France&quot; = &quot;FR&quot;,
-                             &quot;Germany (until 1990 former territory of the FRG)&quot; = &quot;DE&quot;,
-                             &quot;Greece&quot; = &quot;EL&quot;,
-                             &quot;Hungary&quot; = &quot;HU&quot;,
-                             &quot;Ireland&quot; = &quot;IE&quot;,
-                             &quot;Italy&quot; = &quot;IT&quot;,
-                             &quot;Latvia&quot; = &quot;LV&quot;,
-                             &quot;Lithuania&quot; = &quot;LT&quot;,
-                             &quot;Luxembourg&quot; = &quot;LU&quot;,
-                             &quot;Malta&quot; = &quot;MT&quot;,
-                             &quot;Netherlands&quot; = &quot;NL&quot;,
-                             &quot;Norway&quot; = &quot;NO&quot;,
-                             &quot;Poland&quot; = &quot;PL&quot;,
-                             &quot;Portugal&quot; = &quot;PT&quot;,
-                             &quot;Romania&quot; = &quot;RO&quot;,
-                             &quot;Slovakia&quot; = &quot;SK&quot;,
-                             &quot;Slovenia&quot; = &quot;SI&quot;,
-                             &quot;Spain&quot; = &quot;ES&quot;,
-                             &quot;Sweden&quot; = &quot;SE&quot;,
-                             &quot;Turkey&quot; = &quot;TR&quot;,
-                             &quot;United Kingdom&quot; = &quot;UK&quot;,
-                             &quot;Bulgaria&quot; = &quot;BG&quot;,
-                             &quot;Croatia&quot; = &quot;HR&quot;)) %&gt;%
-  select(NACE_R2,AIRPOL,geo,Value) %&gt;%
-  mutate(Value = parse_number(Value),
-         Value = as.numeric(Value)) %&gt;%
-  spread(NACE_R2,Value) %&gt;%
-  clean_names() %&gt;%
-  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) %&gt;%
-  select(geo,airpol,HH_HEAT,HH_TRA,HH_OTH) 
-
-
-env_ac_ainah_r2_co2 = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Carbon dioxide&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_co2,-geo)
-
-env_ac_ainah_r2_ch4 = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Methane&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_ch4,-geo)
-
-env_ac_ainah_r2_n2o = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Nitrous oxide&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_n2o,-geo)
-
-direct_FD_fp_long = national_fp %&gt;%
-  filter(fd_category == &quot;Final consumption expenditure by households&quot;,
-         geo %in% c(&quot;AT&quot;,
-                    &quot;BE&quot;, &quot;BG&quot;, &quot;CY&quot;, &quot;CZ&quot;,
-                    &quot;DE&quot; , &quot;DK&quot; , &quot;EE&quot; , 
-                    &quot;ES&quot; , &quot;FI&quot; , &quot;FR&quot; , 
-                    &quot;UK&quot;, &quot;EL&quot;, &quot;HR&quot; ,
-                    &quot;HU&quot; , &quot;IE&quot; , &quot;IT&quot; ,
-                    &quot;LT&quot; , &quot;LU&quot; , &quot;LV&quot; ,
-                    &quot;MT&quot; , &quot;NL&quot; , &quot;PL&quot; ,
-                    &quot;PT&quot; , &quot;TR&quot; , &quot;SK&quot; ,
-                    &quot;SI&quot; , &quot;SE&quot; , &quot;RO&quot; ,
-                    &quot;NO&quot;)) %&gt;%
-  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) %&gt;%   
-  slice(rep(1:n(), each = 3)) 
-
-sector = rep(c(&quot;HH_HEAT&quot;,&quot;HH_TRA&quot;,&quot;HH_OTH&quot;), nrow(direct_FD_fp_long)/3) 
-
-direct_FD_fp_long_disagg = cbind(sector,direct_FD_fp_long) %&gt;%
-  mutate(coicop = ifelse(sector == &quot;HH_TRA&quot;,&quot;CP072&quot;,
-                         ifelse(sector == &quot;HH_HEAT&quot;,&quot;CP045&quot;,&quot;CP05&quot;)), 
-         five_sectors = ifelse(sector == &quot;HH_TRA&quot;, &quot;transport&quot;,
-                               ifelse(sector == &quot;HH_HEAT&quot;, &quot;shelter&quot;, &quot;manufactured goods&quot;))) %&gt;%
-  left_join(env_ac_ainah_r2_co2, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_ainah_r2_ch4, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_ainah_r2_n2o, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_pefasu, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  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) %&gt;%
-  left_join(shares, by = c(&quot;year&quot;,&quot;geo&quot;,&quot;coicop&quot;)) %&gt;%
-  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) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_co2) %&gt;%
-  spread(quintile,disaggregated_direct_FD_co2) %&gt;%
-  rename(q1_co2 = QUINTILE1,
-         q2_co2 = QUINTILE2,
-         q3_co2 = QUINTILE3,
-         q4_co2 = QUINTILE4,
-         q5_co2 = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_ch4) %&gt;%
-  spread(quintile,disaggregated_direct_FD_ch4) %&gt;%
-  rename(q1_ch4 = QUINTILE1,
-         q2_ch4 = QUINTILE2,
-         q3_ch4 = QUINTILE3,
-         q4_ch4 = QUINTILE4,
-         q5_ch4 = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_n2o) %&gt;%
-  spread(quintile,disaggregated_direct_FD_n2o) %&gt;%
-  rename(q1_n2o = QUINTILE1,
-         q2_n2o = QUINTILE2,
-         q3_n2o = QUINTILE3,
-         q4_n2o = QUINTILE4,
-         q5_n2o = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_energy) %&gt;%
-  spread(quintile,disaggregated_direct_FD_energy) %&gt;%
-  rename(q1_energy = QUINTILE1,
-         q2_energy = QUINTILE2,
-         q3_energy = QUINTILE3,
-         q4_energy = QUINTILE4,
-         q5_energy = QUINTILE5) %&gt;%
-  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 %&gt;%
-  left_join(direct_FD_ch4, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                  &quot;sector&quot;,&quot;coicop&quot;,
-                                  &quot;five_sectors&quot;)) %&gt;%
-  left_join(direct_FD_n2o, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                  &quot;sector&quot;,&quot;coicop&quot;,
-                                  &quot;five_sectors&quot;)) %&gt;%
-  left_join(direct_FD_energy, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                     &quot;sector&quot;,&quot;coicop&quot;,
-                                     &quot;five_sectors&quot;)) %&gt;%
-  mutate(country_of_production = geo) %&gt;%
-  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) %&gt;%
-  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 %&gt;%
-  left_join(TIVs, by = c(&quot;year&quot;, &quot;country_of_production&quot;, &quot;coicop&quot;, &quot;sector&quot;)) %&gt;%
-  left_join(europe_TIVs, by = c(&quot;year&quot;, &quot;country_of_production&quot;, &quot;coicop&quot;, &quot;sector&quot;, &quot;five_sectors&quot;)) %&gt;%
-  left_join(domestic_TIVs, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;country_of_production&quot;, &quot;coicop&quot;, &quot;sector&quot;, &quot;five_sectors&quot;)) %&gt;%
-  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, &quot;/results_no_rent_ixi.csv&quot;))
-
-
-### create compressed results_ixi rds file
-
-#if (!require(&quot;pacman&quot;)) install.packages(&quot;pacman&quot;)
-#pacman::p_load(tidyverse,
-#               janitor,
-#               here)
-
-#dat_all = read_csv(here(&quot;data/results_ixi.csv&quot;)) %&gt;%
-#  clean_names()
-
-dat_all = results_with_direct_FD_fp %&gt;%
-  clean_names()
-
-# convert sector labels to IDs
-sectors = dat_all %&gt;%
-  distinct(sector) %&gt;%
-  mutate(sector_id = row_number())
-
-#write_csv(sectors, here(&quot;data/sector_labels.csv&quot;))
-write_csv(sectors, paste0(data_dir_income_stratified_footprints, &quot;/sectors_method1_pxp_pps_hh.csv&quot;))
-
-# convert aggregated sector labels to IDs
-sectors_agg = dat_all %&gt;%
-  distinct(five_sectors) %&gt;%
-  mutate(sector_agg_id = row_number())
-
-#write_csv(sectors_agg, here(&quot;data/sector_agg_labels.csv&quot;))
-write_csv(sectors_agg, paste0(data_dir_income_stratified_footprints, &quot;/sectors_agg_method1_pxp_pps_hh.csv&quot;))
-
-# convert COICOP labels to IDs
-coicop = dat_all %&gt;%
-  distinct(coicop) %&gt;%
-  mutate(coicop_id = row_number()) 
-
-#write_csv(sectors_agg, here(&quot;data/sector_agg_labels.csv&quot;))
-write_csv(coicop, paste0(data_dir_income_stratified_footprints, &quot;/coicop_method1_pxp_pps_hh.csv&quot;))
-
-# replace sector text labels with numerical IDs (save space)
-dat_compressed = dat_all %&gt;%
-  left_join(sectors, by=&quot;sector&quot;) %&gt;%
-  left_join(sectors_agg, by=&quot;five_sectors&quot;) %&gt;%
-  left_join(coicop, by = &quot;coicop&quot;) %&gt;%
-  select(-c(sector, five_sectors,coicop))
-
-# extract sector aggregation
-sector_mapping = dat_compressed %&gt;%
-  group_by(sector_id) %&gt;%
-  summarise(sector_agg_id = first(sector_agg_id),
-            coicop_id = first(coicop_id))
-
-# collapse country of origin
-dat_results = dat_compressed %&gt;%
-  select(-sector_agg_id,-coicop_id) %&gt;%
-  group_by(year, geo, sector_id) %&gt;%
-  summarise_if(is.numeric, sum, na.rm = TRUE)
-
-## extract final demand and pivot long
-cols_final_demand = c(&quot;quintile1&quot;, &quot;quintile2&quot;, &quot;quintile3&quot;, &quot;quintile4&quot;, &quot;quintile5&quot;)
-tmp_fd = dat_results %&gt;%
-  select(year, geo, sector_id, cols_final_demand) %&gt;%
-  pivot_longer(cols = cols_final_demand,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;fd_me&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 and pivot long
-cols_co2 = c(&quot;q1_co2&quot;, &quot;q2_co2&quot;, &quot;q3_co2&quot;, &quot;q4_co2&quot;, &quot;q5_co2&quot;)
-tmp_co2 = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2) %&gt;%
-  pivot_longer(cols = cols_co2,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 domestic and pivot long
-cols_co2_domestic = c(&quot;q1_co2_domestic&quot;, &quot;q2_co2_domestic&quot;, &quot;q3_co2_domestic&quot;, &quot;q4_co2_domestic&quot;, &quot;q5_co2_domestic&quot;)
-tmp_co2_domestic = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2_domestic) %&gt;%
-  pivot_longer(cols = cols_co2_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_domestic_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 europe and pivot long
-cols_co2_europe = c(&quot;q1_co2_europe&quot;, &quot;q2_co2_europe&quot;, &quot;q3_co2_europe&quot;, &quot;q4_co2_europe&quot;, &quot;q5_co2_europe&quot;)
-tmp_co2_europe = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2_europe) %&gt;%
-  pivot_longer(cols = cols_co2_europe,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_europe_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-
-## extract co2eq and pivot long
-cols_co2eq = c(&quot;q1_co2eq&quot;, &quot;q2_co2eq&quot;, &quot;q3_co2eq&quot;, &quot;q4_co2eq&quot;, &quot;q5_co2eq&quot;)
-tmp_co2eq = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2eq) %&gt;%
-  pivot_longer(cols = cols_co2eq,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2eq domestic and pivot long
-cols_co2eq_domestic = c(&quot;q1_co2eq_domestic&quot;, &quot;q2_co2eq_domestic&quot;, &quot;q3_co2eq_domestic&quot;, &quot;q4_co2eq_domestic&quot;, &quot;q5_co2eq_domestic&quot;)
-tmp_co2eq_domestic = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2eq_domestic) %&gt;%
-  pivot_longer(cols = cols_co2eq_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_domestic_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2eq europe and pivot long
-cols_co2eq_europe = c(&quot;q1_co2eq_europe&quot;, &quot;q2_co2eq_europe&quot;, &quot;q3_co2eq_europe&quot;, &quot;q4_co2eq_europe&quot;, &quot;q5_co2eq_europe&quot;)
-tmp_co2eq_europe = dat_results %&gt;%
-  select(year, geo, sector_id, cols_co2eq_europe) %&gt;%
-  pivot_longer(cols = cols_co2eq_europe,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_europe_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy use and pivot long
-cols_energy = c(&quot;q1_energy&quot;,&quot;q2_energy&quot;,&quot;q3_energy&quot;,&quot;q4_energy&quot;,&quot;q5_energy&quot;)
-tmp_energy = dat_results %&gt;%
-  select(year, geo, sector_id, cols_energy) %&gt;%
-  pivot_longer(cols = cols_energy,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy domestic and pivot long
-cols_energy_domestic = c(&quot;q1_energy_domestic&quot;,&quot;q2_energy_domestic&quot;,&quot;q3_energy_domestic&quot;,&quot;q4_energy_domestic&quot;,&quot;q5_energy_domestic&quot;)
-tmp_energy_domestic = dat_results %&gt;%
-  select(year, geo, sector_id, cols_energy_domestic) %&gt;%
-  pivot_longer(cols = cols_energy_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_domestic_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy europe and pivot long
-cols_energy_europe = c(&quot;q1_energy_europe&quot;,&quot;q2_energy_europe&quot;,&quot;q3_energy_europe&quot;,&quot;q4_energy_europe&quot;,&quot;q5_energy_europe&quot;)
-tmp_energy_europe = dat_results %&gt;%
-  select(year, geo, sector_id, cols_energy_europe) %&gt;%
-  pivot_longer(cols = cols_energy_europe,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_europe_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-### TODO: also convert to other indicators to this format (as blocks above)
-### TODO: left join all indicators back to &quot;results_formated&quot; like her with co2
-results_recombined = tmp_fd %&gt;%
-  left_join(tmp_co2, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2_europe, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq_europe, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy_europe, by = c(&quot;year&quot;, &quot;geo&quot;, &quot;sector_id&quot;, &quot;quint&quot;))
-
-
-
-# finally re-join aggregated sector IDs
-results_formatted = results_recombined %&gt;% 
-  left_join(sector_mapping, by=&quot;sector_id&quot;) %&gt;%
-  ungroup() %&gt;%
-  select(-coicop_id)
-
-#write_rds(results_formated, here(&quot;/results_formated.rds&quot;))
-
-write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_pxp_pps_hh_no_rent.csv&quot;))
-
-#write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_pxp_pps_hh_no_rent.rds&quot;))
-
-
-#write.csv(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_pxp_pps_ae.csv&quot;))
-#write_rds(results_formatted, paste0(data_dir_income_stratified_footprints, &quot;/results_formatted_method1_pxp_pps_ae.rds&quot;))
-
-
-
-
-
-
-
-################################################### !!!! method 2 !!!! - IXI version - PPS HH - RENT NOT MAPPED TO EXIOBASE !!!!! #############################
-###############################################################################################################################################################
-###############################################################################################################################################################
-
-
-# &#39;results&#39; data frame the second way
-
-# aggregate - playing around trying to go the other way
-
-# load &#39;mean expenditure by quintile&#39; data
-hbs_exp_t133 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/hbs_exp_t133.csv&quot;))
-# rename and arrange by country
-mean_expenditure_by_quintile = hbs_exp_t133 %&gt;% 
-  rename(geo = 3, quintile = &quot;quantile&quot;) %&gt;%
-  arrange(geo)
-
-# load &#39;mean expenditure by quintile and coicop&#39; data
-hbs_str_t223 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/hbs_str_t223.csv&quot;))
-# rename and arrange by country
-mean_expenditure_by_coicop_sector = hbs_str_t223 %&gt;% 
-  rename(geo = 4, quintile = &quot;quantile&quot;) %&gt;%
-  arrange(geo) 
-
-# create long data sets for both
-
-mean_expenditure_by_quintile_long = mean_expenditure_by_quintile %&gt;%
-  filter(unit == &quot;PPS_HH&quot;) %&gt;%
-  filter(!(quintile %in% c(&quot;UNK&quot;,&quot;TOTAL&quot;))) %&gt;%
-  select(-unit) %&gt;%
-  gather(year,euro_pps,-quintile,-geo) 
-
-mean_expenditure_by_coicop_sector_long = mean_expenditure_by_coicop_sector %&gt;% 
-  filter(!(quintile %in% c(&quot;UNK&quot;,&quot;TOTAL&quot;))) %&gt;%
-  select(-unit) %&gt;%
-  gather(year,pm,-quintile,-coicop,-geo) %&gt;%
-  mutate(coicop = dplyr::recode(coicop, &quot;CP041&quot; = &quot;rent&quot;,        
-                                &quot;CP042&quot; = &quot;rent&quot;)) %&gt;%           
-  group_by(geo,quintile,coicop,year) %&gt;%                               
-  mutate(pm = parse_number(pm),
-         pm = as.numeric(pm)) %&gt;%
-  summarise(pm = sum(pm, na.rm = TRUE)) %&gt;%
-  ungroup() %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE1&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 92-21-14,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE2&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 108-22-12,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE3&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 124-32-11,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE4&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 133-43-10,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2005 &amp; quintile == &quot;QUINTILE5&quot; &amp; 
-                       coicop == &quot;CP072&quot;, 162-81-11,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE1&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 412-4-78-322,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE2&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 355-5-68-265,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE3&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 325-8-64-229,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE4&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 300-9-58-204,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2010 &amp; quintile == &quot;QUINTILE5&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 249-10-46-167,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE1&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 433-3-82-340,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE2&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 376-6-70-284,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE3&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 351-9-67-251,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE4&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 326-10-61-228,pm)) %&gt;%
-  mutate(pm = ifelse(geo == &quot;DE&quot; &amp; year == 2015 &amp; quintile == &quot;QUINTILE5&quot; &amp; 
-                       coicop == &quot;CP044&quot;, 280-9-49-195,pm))
-
-join_expenditures = mean_expenditure_by_coicop_sector_long %&gt;% 
-  left_join(mean_expenditure_by_quintile_long, by = c(&quot;geo&quot;,&quot;quintile&quot;,&quot;year&quot;)) %&gt;%
-  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, &quot;/data/SNA_TABLE45_20042020103737298.csv&quot;)) %&gt;%
-  select(LOCATION, PRODUCT, Product, Year, Value) %&gt;% 
-  mutate(geo = dplyr::recode(LOCATION,&quot;AUT&quot; = &quot;AT&quot;, 
-                             &quot;BEL&quot; = &quot;BE&quot;,
-                             &quot;CYP&quot; = &quot;CY&quot;,
-                             &quot;CZE&quot; = &quot;CZ&quot;,
-                             &quot;DNK&quot; = &quot;DK&quot;,
-                             &quot;EST&quot; = &quot;EE&quot;,
-                             &quot;FIN&quot; = &quot;FI&quot;,
-                             &quot;FRA&quot; = &quot;FR&quot;,
-                             &quot;DEU&quot; = &quot;DE&quot;,
-                             &quot;GRC&quot; = &quot;EL&quot;,
-                             &quot;HUN&quot; = &quot;HU&quot;,
-                             &quot;IRL&quot; = &quot;IE&quot;,
-                             &quot;ITA&quot; = &quot;IT&quot;,
-                             &quot;LVA&quot; = &quot;LV&quot;,
-                             &quot;LTU&quot; = &quot;LT&quot;,
-                             &quot;LUX&quot; = &quot;LU&quot;,
-                             &quot;MLT&quot; = &quot;MT&quot;,
-                             &quot;MNE&quot; = &quot;ME&quot;,
-                             &quot;NLD&quot; = &quot;NL&quot;,
-                             &quot;NOR&quot; = &quot;NO&quot;,
-                             &quot;POL&quot; = &quot;PL&quot;,
-                             &quot;PRT&quot; = &quot;PT&quot;,
-                             &quot;ROU&quot; = &quot;RO&quot;,
-                             &quot;SRB&quot; = &quot;RS&quot;,
-                             &quot;SVK&quot; = &quot;SK&quot;,
-                             &quot;SVN&quot; = &quot;SI&quot;,
-                             &quot;ESP&quot; = &quot;ES&quot;,
-                             &quot;SWE&quot; = &quot;SE&quot;,
-                             &quot;CHE&quot; = &quot;CH&quot;,
-                             &quot;MKD&quot; = &quot;MK&quot;,
-                             &quot;TUR&quot; = &quot;TR&quot;,
-                             &quot;GBR&quot; = &quot;UK&quot;,
-                             &quot;BGR&quot; = &quot;BG&quot;,
-                             &quot;HRV&quot; = &quot;HR&quot;)) %&gt;%
-  select(geo, Year, PRODUCT, Value) %&gt;%
-  rename(year = Year,
-         trade_and_transport = Value) %&gt;%
-  mutate(trade_and_transport = trade_and_transport/100) %&gt;%
-  rename(geo_join = geo)
-
-
-
-taxes_less_subsidies = read.csv(paste0(data_dir_income_stratified_footprints, &quot;/data/SNA_TABLE45_20042020104120395.csv&quot;)) %&gt;%
-  select(LOCATION, PRODUCT, Product, Year, Value) %&gt;%
-  mutate(geo = dplyr::recode(LOCATION,&quot;AUT&quot; = &quot;AT&quot;, 
-                             &quot;BEL&quot; = &quot;BE&quot;,
-                             &quot;CYP&quot; = &quot;CY&quot;,
-                             &quot;CZE&quot; = &quot;CZ&quot;,
-                             &quot;DNK&quot; = &quot;DK&quot;,
-                             &quot;EST&quot; = &quot;EE&quot;,
-                             &quot;FIN&quot; = &quot;FI&quot;,
-                             &quot;FRA&quot; = &quot;FR&quot;,
-                             &quot;DEU&quot; = &quot;DE&quot;,
-                             &quot;GRC&quot; = &quot;EL&quot;,
-                             &quot;HUN&quot; = &quot;HU&quot;,
-                             &quot;IRL&quot; = &quot;IE&quot;,
-                             &quot;ITA&quot; = &quot;IT&quot;,
-                             &quot;LVA&quot; = &quot;LV&quot;,
-                             &quot;LTU&quot; = &quot;LT&quot;,
-                             &quot;LUX&quot; = &quot;LU&quot;,
-                             &quot;MLT&quot; = &quot;MT&quot;,
-                             &quot;MNE&quot; = &quot;ME&quot;,
-                             &quot;NLD&quot; = &quot;NL&quot;,
-                             &quot;NOR&quot; = &quot;NO&quot;,
-                             &quot;POL&quot; = &quot;PL&quot;,
-                             &quot;PRT&quot; = &quot;PT&quot;,
-                             &quot;ROU&quot; = &quot;RO&quot;,
-                             &quot;SRB&quot; = &quot;RS&quot;,
-                             &quot;SVK&quot; = &quot;SK&quot;,
-                             &quot;SVN&quot; = &quot;SI&quot;,
-                             &quot;ESP&quot; = &quot;ES&quot;,
-                             &quot;SWE&quot; = &quot;SE&quot;,
-                             &quot;CHE&quot; = &quot;CH&quot;,
-                             &quot;MKD&quot; = &quot;MK&quot;,
-                             &quot;TUR&quot; = &quot;TR&quot;,
-                             &quot;GBR&quot; = &quot;UK&quot;,
-                             &quot;BGR&quot; = &quot;BG&quot;,
-                             &quot;HRV&quot; = &quot;HR&quot;)) %&gt;%
-  select(geo, Year, PRODUCT, Value) %&gt;%
-  rename(year = Year,
-         taxes_less_subsidies = Value) %&gt;%
-  mutate(taxes_less_subsidies = taxes_less_subsidies/100) %&gt;%
-  rename(geo_join = geo)
-
-# create margins dataframe
-
-geo_real = rep(c(&quot;AT&quot;, 
-                 &quot;BE&quot;,
-                 &quot;CY&quot;,
-                 &quot;CZ&quot;,
-                 &quot;DK&quot;,
-                 &quot;EE&quot;,
-                 &quot;FI&quot;,
-                 &quot;FR&quot;,
-                 &quot;DE&quot;,
-                 &quot;EL&quot;,
-                 &quot;HU&quot;,
-                 &quot;IE&quot;,
-                 &quot;IT&quot;,
-                 &quot;LV&quot;,
-                 &quot;LT&quot;,
-                 &quot;LU&quot;,
-                 &quot;MT&quot;,
-                 &quot;ME&quot;,
-                 &quot;NL&quot;,
-                 &quot;NO&quot;,
-                 &quot;PL&quot;,
-                 &quot;PT&quot;,
-                 &quot;RO&quot;,
-                 &quot;RS&quot;,
-                 &quot;SK&quot;,
-                 &quot;SI&quot;,
-                 &quot;ES&quot;,
-                 &quot;SE&quot;,
-                 &quot;MK&quot;,
-                 &quot;TR&quot;,
-                 &quot;UK&quot;,
-                 &quot;BG&quot;,
-                 &quot;HR&quot;),each = 16)
-
-geo_join = rep(c(&quot;AT&quot;, 
-                 &quot;BE&quot;,
-                 &quot;CY&quot;,
-                 &quot;CZ&quot;,
-                 &quot;DK&quot;,
-                 &quot;LV&quot;,
-                 &quot;FI&quot;,
-                 &quot;FR&quot;,
-                 &quot;AT&quot;,
-                 &quot;EL&quot;,
-                 &quot;HU&quot;,
-                 &quot;UK&quot;,
-                 &quot;IT&quot;,
-                 &quot;LV&quot;,
-                 &quot;LV&quot;,
-                 &quot;LU&quot;,
-                 &quot;MT&quot;,
-                 &quot;ME&quot;,
-                 &quot;NL&quot;,
-                 &quot;FI&quot;,
-                 &quot;PL&quot;,
-                 &quot;PT&quot;,
-                 &quot;RO&quot;,
-                 &quot;RS&quot;,
-                 &quot;SK&quot;,
-                 &quot;SI&quot;,
-                 &quot;PT&quot;,
-                 &quot;FI&quot;,
-                 &quot;MK&quot;,
-                 &quot;BG&quot;,
-                 &quot;UK&quot;,
-                 &quot;BG&quot;,
-                 &quot;HR&quot;),each = 16)
-
-year = rep(2010,length(geo_real))
-
-PRODUCT = c(&quot;P10_12&quot;,
-            &quot;P13_15&quot;,
-            &quot;P68A&quot;,
-            &quot;PF&quot;,
-            &quot;PE&quot;,
-            &quot;PD&quot;,
-            &quot;PC&quot;,
-            &quot;PQ&quot;,
-            &quot;P29&quot;,
-            &quot;P19&quot;,
-            &quot;P30&quot;,
-            &quot;P61&quot;,
-            &quot;PR&quot;,
-            &quot;PP&quot;,
-            &quot;PI&quot;,
-            &quot;PS&quot;)
-
-margin_sectors = data.frame(geo_real,geo_join,year,PRODUCT)
-
-# join everything - and impute
-
-margins = margin_sectors %&gt;%
-  left_join(taxes_less_subsidies, by = c(&quot;geo_join&quot;,&quot;year&quot;,&quot;PRODUCT&quot;)) %&gt;%
-  left_join(trade_and_transport, by = c(&quot;geo_join&quot;,&quot;year&quot;,&quot;PRODUCT&quot;)) %&gt;%
-  select(-geo_join) %&gt;%
-  rename(geo = geo_real) %&gt;%
-  mutate(taxes_less_subsidies = ifelse(geo == &quot;CZ&quot; &amp; PRODUCT == &quot;P68A&quot;, 0, taxes_less_subsidies)) %&gt;%
-  mutate(trade_and_transport = ifelse(geo == &quot;CZ&quot; &amp; PRODUCT == &quot;P68A&quot;, 0, trade_and_transport)) %&gt;%
-  mutate(taxes_less_subsidies = ifelse(geo == &quot;SK&quot; &amp; PRODUCT == &quot;P68A&quot;, 0, taxes_less_subsidies)) %&gt;%
-  mutate(trade_and_transport = ifelse(geo == &quot;SK&quot; &amp; PRODUCT == &quot;P68A&quot;, 0, trade_and_transport)) %&gt;%
-  select(-year)
-
-
-# join margin data to join_expenditures 
-
-with_margins = join_expenditures %&gt;%
-  mutate(year = as.numeric(year),
-         PRODUCT = dplyr::recode(coicop,
-                                 &quot;CP011&quot; =  &quot;P10_12&quot;,
-                                 &quot;CP012&quot; =  &quot;P10_12&quot;,
-                                 &quot;CP02&quot; = &quot;P10_12&quot;,
-                                 &quot;CP03&quot; = &quot;P13_15&quot;,
-                                 &quot;rent&quot; = &quot;P68A&quot;,
-                                 &quot;CP043&quot; = &quot;PF&quot;,
-                                 &quot;CP044&quot; = &quot;PE&quot;,
-                                 &quot;CP045&quot; = &quot;PD&quot;,
-                                 &quot;CP05&quot; = &quot;PC&quot;,
-                                 &quot;CP06&quot; = &quot;PQ&quot;,
-                                 &quot;CP071&quot; = &quot;P29&quot;,
-                                 &quot;CP072&quot; = &quot;P19&quot;,
-                                 &quot;CP073&quot; = &quot;P30&quot;,
-                                 &quot;CP08&quot; = &quot;P61&quot;,
-                                 &quot;CP09&quot; = &quot;PR&quot;,
-                                 &quot;CP10&quot; = &quot;PP&quot;,
-                                 &quot;CP11&quot; = &quot;PI&quot;,
-                                 &quot;CP12&quot; = &quot;PS&quot;)) %&gt;%
-  left_join(margins, by = c(&quot;geo&quot;,&quot;PRODUCT&quot;)) %&gt;%
-  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 %&gt;%
-  group_by(quintile,geo,year) %&gt;%
-  summarise(euro_pps_bp = sum(euro_pps_coicop_bp, na.rm = TRUE))
-
-
-mean_expenditure_by_coicop_sector_long_bp = with_margins %&gt;%
-  left_join(mean_expenditure_by_quintile_long_bp, by = c(&quot;quintile&quot;,&quot;geo&quot;,&quot;year&quot;)) %&gt;%
-  mutate(pm_bp = (euro_pps_coicop_bp/euro_pps_bp)*1000) %&gt;%
-  select(quintile,coicop,geo,year,pm_bp)
-
-
-###
-
-shares = join_expenditures %&gt;%
-  group_by(coicop,geo,year) %&gt;%
-  mutate(share = euro_pps_coicop/sum(euro_pps_coicop))
-
-
-################################################### !!!! method 2 - IXI version - PPS HH NO RENT !!!! ####################################################
-##########################################################################################################################################################
-##########################################################################################################################################################
-
-# pre-processing
-
-data_dir_exiobase = paste(&quot;/&quot;,file.path(&quot;data&quot;,&quot;metab&quot;,&quot;Exiobase&quot;, fsep=.Platform$file.sep),sep=&quot;&quot;)
-
-# 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, &quot;/IOT_&quot;,year_current,&quot;_ixi/FD_&quot;,year_current,&quot;_ixi.csv&quot;))[,-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(&quot;AT&quot;,&quot;BE&quot;,&quot;BG&quot;,&quot;CY&quot;,&quot;CZ&quot;,&quot;DE&quot;,&quot;DK&quot;,&quot;EE&quot;,&quot;EL&quot;,&quot;ES&quot;,&quot;FI&quot;,
-                     &quot;FR&quot;,&quot;HR&quot;,&quot;HU&quot;,&quot;IE&quot;,&quot;IT&quot;,&quot;LT&quot;,&quot;LU&quot;,&quot;LV&quot;,&quot;MT&quot;,&quot;NL&quot;,&quot;NO&quot;,
-                     &quot;PL&quot;,&quot;PT&quot;,&quot;RO&quot;,&quot;SE&quot;,&quot;SI&quot;,&quot;SK&quot;,&quot;TR&quot;,&quot;UK&quot;)) %&gt;% rename_at(1,~&quot;geo&quot;)
-  
-  year = rep(year_current, 30)
-  
-  fds = cbind(geo,year,eurostat_countries_colsums) %&gt;% slice(rep(1:n(), each = 5))
-  
-  quintiles = data.frame(rep(c(&quot;QUINTILE1&quot;,&quot;QUINTILE2&quot;,&quot;QUINTILE3&quot;,&quot;QUINTILE4&quot;,&quot;QUINTILE5&quot;),30)) %&gt;% rename_at(1,~&quot;quintile&quot;)
-  
-  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, &quot;/data/Exiobase_T_labels_ixi_w_coicop_mapping_no_rent.csv&quot;)) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  # TIVs
-  
-  # CO2 - combustion - air
-  
-  Exiobase_TIV_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_combustion_air_&quot;, year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_combustion_air_&quot;, year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CO2_europe,TIV_CO2_not_europe)
-  
-  # CO2 - noncombustion - cement - air
-  
-  Exiobase_TIV_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_noncombustion_cement_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_noncombustion_cement_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_cement_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_noncombustion_lime_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_noncombustion_lime_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_noncombustion_lime_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_agriculture_peatdecay_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_agriculture_peatdecay_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_agriculture_peatdecay_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_waste_biogenic_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_waste_biogenic_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_biogenic_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CO2_waste_fossil_domestic)
-  
-  Exiobase_TIV_europe_breakdown_co2_waste_fossil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_co2_waste_fossil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_combustion_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_europe,TIV_CH4_not_europe)
-  
-  # CH4 - noncombustion - gas - air
-  
-  Exiobase_TIV_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_gas_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_gas_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_gas_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_gas_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_oil_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_oil_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_oil_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oil_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_anthracite_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_anthracite_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_anthracite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_anthracite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_bituminouscoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_bituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_bituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_cokingcoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_cokingcoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_cokingcoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_lignite_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_lignite_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_lignite_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_lignite_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_subbituminouscoal_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_subbituminouscoal_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_subbituminouscoal_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_noncombustion_oilrefinery_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_noncombustion_oilrefinery_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_noncombustion_oilrefinery_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_agriculture_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_agriculture_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_agriculture_europe,TIV_CH4_agriculture_not_europe)
-  
-  # CH4 - waste - air
-  
-  Exiobase_TIV_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ch4_CO2eq_waste_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_CH4_waste_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ch4_waste_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ch4_CO2eq_waste_air_&quot;, year_current, &quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_CH4_waste_europe,TIV_CH4_waste_not_europe)
-  
-  
-  # N2O - combustion - air
-  
-  Exiobase_TIV_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_N2O_domestic)
-  
-  Exiobase_TIV_europe_breakdown_n2o_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_combustion_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_N2O_europe,TIV_N2O_not_europe)
-  
-  # N2O - agriculture - air
-  
-  Exiobase_TIV_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_N2O_agriculture_domestic)
-  
-  Exiobase_TIV_europe_breakdown_n2o_agriculture_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_n2o_CO2eq_agriculture_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_N2O_agriculture_europe,TIV_N2O_agriculture_not_europe)
-  
-  # SF6 - air
-  
-  Exiobase_TIV_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_SF6_domestic)
-  
-  Exiobase_TIV_europe_breakdown_sf6_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_sf6_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_SF6_europe,TIV_SF6_not_europe)
-  
-  # HFC - air
-  
-  Exiobase_TIV_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_HFC_domestic)
-  
-  Exiobase_TIV_europe_breakdown_hfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_hfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_HFC_europe,TIV_HFC_not_europe)
-  
-  # PFC - air
-  
-  Exiobase_TIV_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_PFC_domestic)
-  
-  Exiobase_TIV_europe_breakdown_pfc_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pfc_CO2eq_air_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_PFC_europe,TIV_PFC_not_europe)
-  
-  # Energy use
-  
-  Exiobase_TIV_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_energy_domestic)
-  
-  Exiobase_TIV_europe_breakdown_energy_use_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_energy_carrier_use_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_energy_europe,TIV_energy_not_europe)
-  
-  # biomass
-  
-  Exiobase_TIV_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_biomass_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_biomass_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_biomass_domestic)
-  
-  Exiobase_TIV_europe_breakdown_biomass_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_biomass_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_biomass_europe,TIV_biomass_not_europe)
-  
-  # construction materials
-  
-  Exiobase_TIV_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_const_materials_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_const_materials_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_const_materials_domestic)
-  
-  Exiobase_TIV_europe_breakdown_const_materials_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_const_materials_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_const_materials_europe,TIV_const_materials_not_europe)
-  
-  # fossil fuels
-  
-  Exiobase_TIV_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ffuels_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ffuels_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_ffuels_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ffuels_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ffuels_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_ffuels_europe,TIV_ffuels_not_europe)
-  
-  # ores
-  
-  Exiobase_TIV_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_ores_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ores_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_ores_domestic)
-  
-  Exiobase_TIV_europe_breakdown_ores_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_ores_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_ores_europe,TIV_ores_not_europe)
-  
-  # cropland
-  
-  Exiobase_TIV_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_cropland_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_cropland_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_cropland_domestic)
-  
-  Exiobase_TIV_europe_breakdown_cropland_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_cropland_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_cropland_europe,TIV_cropland_not_europe)
-  
-  # forest land
-  
-  Exiobase_TIV_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_forest_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_forest_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_forest_land_domestic)
-  
-  Exiobase_TIV_europe_breakdown_forest_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_forest_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    select(TIV_forest_land_europe,TIV_forest_land_not_europe)
-  
-  # pasture land
-  
-  Exiobase_TIV_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_pasture_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1]
-  
-  Exiobase_TIV_country_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pasture_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    gather(country, TIV_pasture_land_domestic)
-  
-  Exiobase_TIV_europe_breakdown_pasture_land_bp = read.csv(paste0(data_dir_exiobase, &quot;/IOT_&quot;,year_current,&quot;_ixi/TIV_country_breakdown_pasture_land_&quot;,year_current,&quot;_ixi.csv&quot;))[,-1] %&gt;%
-    row_to_names(row_number = 1) %&gt;%
-    mutate_at(vars(AT:ZA), funs(as.numeric(as.character(.)))) %&gt;%
-    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) %&gt;%
-    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)) %&gt;% 
-    rename(TIV_CO2 = &quot;t(Exiobase_TIV_co2_bp)&quot;,
-           TIV_CO2_noncombustion_cement = &quot;t(Exiobase_TIV_co2_noncombustion_cement_bp)&quot;,
-           TIV_CO2_noncombustion_lime = &quot;t(Exiobase_TIV_co2_noncombustion_lime_bp)&quot;,
-           TIV_CO2_agriculture_peatdecay = &quot;t(Exiobase_TIV_co2_agriculture_peatdecay_bp)&quot;,
-           TIV_CO2_waste_biogenic = &quot;t(Exiobase_TIV_co2_waste_biogenic_bp)&quot;,
-           TIV_CO2_waste_fossil = &quot;t(Exiobase_TIV_co2_waste_fossil_bp)&quot;,
-           TIV_CH4 = &quot;t(Exiobase_TIV_ch4_bp)&quot;,
-           TIV_CH4_noncombustion_gas = &quot;t(Exiobase_TIV_ch4_noncombustion_gas_bp)&quot;,
-           TIV_CH4_noncombustion_oil = &quot;t(Exiobase_TIV_ch4_noncombustion_oil_bp)&quot;,
-           TIV_CH4_noncombustion_anthracite = &quot;t(Exiobase_TIV_ch4_noncombustion_anthracite_bp)&quot;,
-           TIV_CH4_noncombustion_bituminouscoal = &quot;t(Exiobase_TIV_ch4_noncombustion_bituminouscoal_bp)&quot;,
-           TIV_CH4_noncombustion_cokingcoal = &quot;t(Exiobase_TIV_ch4_noncombustion_cokingcoal_bp)&quot;,
-           TIV_CH4_noncombustion_lignite = &quot;t(Exiobase_TIV_ch4_noncombustion_lignite_bp)&quot;,
-           TIV_CH4_noncombustion_subbituminouscoal = &quot;t(Exiobase_TIV_ch4_noncombustion_subbituminouscoal_bp)&quot;,
-           TIV_CH4_noncombustion_oilrefinery = &quot;t(Exiobase_TIV_ch4_noncombustion_oilrefinery_bp)&quot;,
-           TIV_CH4_agriculture = &quot;t(Exiobase_TIV_ch4_agriculture_bp)&quot;,
-           TIV_CH4_waste = &quot;t(Exiobase_TIV_ch4_waste_bp)&quot;,
-           TIV_N2O = &quot;t(Exiobase_TIV_n2o_bp)&quot;,
-           TIV_N2O_agriculture = &quot;t(Exiobase_TIV_n2o_agriculture_bp)&quot;,
-           TIV_SF6 = &quot;t(Exiobase_TIV_sf6_bp)&quot;,
-           TIV_HFC = &quot;t(Exiobase_TIV_hfc_bp)&quot;,
-           TIV_PFC = &quot;t(Exiobase_TIV_pfc_bp)&quot;,
-           TIV_energy = &quot;t(Exiobase_TIV_energy_use_bp)&quot;,
-           TIV_biomass = &quot;t(Exiobase_TIV_biomass_bp)&quot;,
-           TIV_const_materials = &quot;t(Exiobase_TIV_const_materials_bp)&quot;,
-           TIV_ffuels = &quot;t(Exiobase_TIV_ffuels_bp)&quot;,
-           TIV_ores = &quot;t(Exiobase_TIV_ores_bp)&quot;,
-           TIV_cropland = &quot;t(Exiobase_TIV_cropland_bp)&quot;,
-           TIV_forest_land = &quot;t(Exiobase_TIV_forest_land_bp)&quot;,
-           TIV_pasture_land = &quot;t(Exiobase_TIV_pasture_land_bp)&quot;) %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;))  
-  
-  year = as.character(rep(year_current,nrow(TIV_with_labels)))
-  
-  look = cbind(year,TIV_with_labels) %&gt;%
-    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 %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_noncombustion_lime_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_agriculture_peatdecay_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_waste_biogenic_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_co2_waste_fossil_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_gas_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_oil_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_anthracite_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_bituminouscoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_cokingcoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_lignite_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_subbituminouscoal_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_noncombustion_oilrefinery_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_agriculture_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ch4_waste_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_n2o_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_n2o_agriculture_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_sf6_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_hfc_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_pfc_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_energy_use_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_biomass_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_const_materials_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ffuels_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_ores_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_cropland_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_forest_land_bp %&gt;% select(-country),
-                                   Exiobase_TIV_country_breakdown_pasture_land_bp %&gt;% select(-country))  %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;),
-           country = dplyr::recode(country, &quot;GR&quot; = &quot;EL&quot;, &quot;GB&quot; = &quot;UK&quot;))  
-  
-  year_domestic = as.character(rep(year_current,nrow(domestic_TIV_with_labels)))
-  
-  look_domestic = cbind(year_domestic,domestic_TIV_with_labels) %&gt;% 
-    rename(country_of_production = V1, sector = V2, geo = country, year = year_domestic) %&gt;%
-    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) %&gt;% 
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  year_europe = as.character(rep(year_current,nrow(europe_TIV_with_labels)))
-  
-  look_europe = cbind(year_europe,europe_TIV_with_labels) %&gt;% 
-    rename(country_of_production = V1, sector = V2, year = year_europe) %&gt;%
-    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, &quot;/Exiobase_FD_labels_ixi.csv&quot;)))[-1,-3]) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  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))) %&gt;%
-    mutate(V1 = dplyr::recode(V1,&quot;GR&quot; = &quot;EL&quot;,&quot;GB&quot; = &quot;UK&quot;)) 
-  
-  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, &quot;/IOT_&quot;, year_current, &quot;_ixi/satellite/F_hh.csv&quot;, sep = &quot;&quot;),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)) %&gt;% 
-    rename(year = year_national_fp,
-           geo = V1, 
-           fd_category = V2, 
-           co2 = &quot;rowSums(t(national_CO2_footprints))&quot;,
-           co2_noncombustion_cement = &quot;rowSums(t(national_CO2_noncombustion_cement_footprints))&quot;,
-           co2_noncombustion_lime = &quot;rowSums(t(national_CO2_noncombustion_lime_footprints))&quot;,
-           co2_agriculture_peatdecay = &quot;rowSums(t(national_CO2_agriculture_peatdecay_footprints))&quot;,
-           co2_waste_biogenic = &quot;rowSums(t(national_CO2_waste_biogenic_footprints))&quot;,
-           co2_waste_fossil = &quot;rowSums(t(national_CO2_waste_fossil_footprints))&quot;,
-           ch4 = &quot;rowSums(t(national_CH4_footprints))&quot;,
-           ch4_noncombustion_gas = &quot;rowSums(t(national_CH4_noncombustion_gas_footprints))&quot;,
-           ch4_noncombustion_oil = &quot;rowSums(t(national_CH4_noncombustion_oil_footprints))&quot;,
-           ch4_noncombustion_anthracite = &quot;rowSums(t(national_CH4_noncombustion_anthracite_footprints))&quot;,
-           ch4_noncombustion_bituminouscoal = &quot;rowSums(t(national_CH4_noncombustion_bituminouscoal_footprints))&quot;,
-           ch4_noncombustion_cokingcoal = &quot;rowSums(t(national_CH4_noncombustion_cokingcoal_footprints))&quot;,
-           ch4_noncombustion_lignite = &quot;rowSums(t(national_CH4_noncombustion_lignite_footprints))&quot;,
-           ch4_noncombustion_subbituminouscoal = &quot;rowSums(t(national_CH4_noncombustion_subbituminouscoal_footprints))&quot;,
-           ch4_noncombustion_oilrefinery = &quot;rowSums(t(national_CH4_noncombustion_oilrefinery_footprints))&quot;,
-           ch4_agriculture = &quot;rowSums(t(national_CH4_agriculture_footprints))&quot;,
-           ch4_waste = &quot;rowSums(t(national_CH4_waste_footprints))&quot;,
-           n2o = &quot;rowSums(t(national_N2O_footprints))&quot;,
-           n2o_agriculture = &quot;rowSums(t(national_N2O_agriculture_footprints))&quot;,
-           sf6 = &quot;rowSums(t(national_SF6_footprints))&quot;,
-           hfc = &quot;rowSums(t(national_HFC_footprints))&quot;,
-           pfc = &quot;rowSums(t(national_PFC_footprints))&quot;,
-           energy = &quot;rowSums(t(national_energy_footprints))&quot;,
-           biomass = &quot;rowSums(t(national_biomass_footprints))&quot;,
-           const_materials = &quot;rowSums(t(national_const_materials_footprints))&quot;,
-           ffuels = &quot;rowSums(t(national_ffuels_footprints))&quot;,
-           ores = &quot;rowSums(t(national_ores_footprints))&quot;,
-           cropland = &quot;rowSums(t(national_cropland_footprints))&quot;,
-           forest_land = &quot;rowSums(t(national_forest_land_footprints))&quot;,
-           pasture_land = &quot;rowSums(t(national_pasture_land_footprints))&quot;) %&gt;%
-    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 %&gt;% 
-  filter(!(quintile %in% c(&quot;TOTAL&quot;,&quot;UNK&quot;))) %&gt;%
-  group_by(geo,year) %&gt;%
-  mutate(euro_pps_bp = as.numeric(euro_pps_bp),
-         mean_exp_shares = euro_pps_bp/sum(euro_pps_bp))
-
-
-ala = total_fd %&gt;%
-  left_join(mean_expenditure_by_quintile_toggle, by = c(&quot;geo&quot;,&quot;year&quot;,&quot;quintile&quot;))
-
-
-
-join_ala = mean_expenditure_by_coicop_sector_long_bp %&gt;%
-  left_join(ala, by = c(&quot;geo&quot;,&quot;quintile&quot;,&quot;year&quot;)) %&gt;%
-  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)) 
-
-
-###################################################
-#%&gt;%
-#  rename(coicop_level1 = coicop)
-
-# TIV only taking the mean
-
-# mean_TIV_with_labels = TIV_with_labels %&gt;% group_by(geo,year,coicop,coicop_level1) %&gt;%
-#  summarise(TIV_CO2 = mean(TIV_CO2)) 
-
-#ok = join_ala %&gt;% left_join(mean_TIV_with_labels, by = c(&quot;geo&quot;,&quot;year&quot;,&quot;coicop&quot;)) %&gt;%
-#  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) %&gt;% select(-year)
-
-weighted_mean_TIV_with_labels = cbind(TIVs,Eurostat_countries_hh_fd_mean_TIV) %&gt;%
-  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) %&gt;%
-  group_by(geo,year,coicop) %&gt;%
-  mutate(fd = as.numeric(fd)) %&gt;%
-  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)) %&gt;%
-  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) %&gt;%
-  unique() 
-
-weighted_mean_europe_TIV_with_labels = cbind(europe_TIVs, Eurostat_countries_hh_fd_mean_TIV) %&gt;%
-  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) %&gt;%
-  group_by(geo,year,coicop) %&gt;%
-  mutate(fd = as.numeric(fd)) %&gt;%
-  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)) %&gt;%
-  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) %&gt;%
-  unique()
-
-domestic_TIVs_Eurostat = domestic_TIVs %&gt;%
-  filter(geo %in% c(&quot;AT&quot;,
-                    &quot;BG&quot;,
-                    &quot;BE&quot;,
-                    &quot;CY&quot;,
-                    &quot;CZ&quot;,
-                    &quot;DE&quot;,
-                    &quot;DK&quot;,
-                    &quot;EE&quot;,
-                    &quot;EL&quot;,
-                    &quot;ES&quot;,
-                    &quot;FI&quot;,
-                    &quot;FR&quot;,
-                    &quot;HR&quot;,
-                    &quot;HU&quot;,
-                    &quot;IE&quot;,
-                    &quot;IT&quot;,
-                    &quot;LT&quot;,
-                    &quot;LU&quot;,
-                    &quot;LV&quot;,
-                    &quot;MT&quot;,
-                    &quot;NL&quot;,
-                    &quot;NO&quot;,
-                    &quot;PL&quot;,
-                    &quot;PT&quot;,
-                    &quot;RO&quot;,
-                    &quot;SE&quot;,
-                    &quot;SI&quot;,
-                    &quot;SK&quot;,
-                    &quot;TR&quot;,
-                    &quot;UK&quot;))
-
-Eurostat_countries_hh_fd_long = as.data.frame(Eurostat_countries_hh_fd) %&gt;%
-  gather(geo,fd,-year) %&gt;%
-  arrange(year, match(geo, c(&quot;AT&quot;,
-                             &quot;BE&quot;,
-                             &quot;BG&quot;,
-                             &quot;CY&quot;,
-                             &quot;CZ&quot;,
-                             &quot;DE&quot;,
-                             &quot;DK&quot;,
-                             &quot;EE&quot;,
-                             &quot;ES&quot;,
-                             &quot;FI&quot;,
-                             &quot;FR&quot;,
-                             &quot;UK&quot;,
-                             &quot;EL&quot;,
-                             &quot;HR&quot;,
-                             &quot;HU&quot;,
-                             &quot;IE&quot;,
-                             &quot;IT&quot;,
-                             &quot;LT&quot;,
-                             &quot;LU&quot;,
-                             &quot;LV&quot;,
-                             &quot;MT&quot;,
-                             &quot;NL&quot;,
-                             &quot;NO&quot;,
-                             &quot;PL&quot;,
-                             &quot;PT&quot;,
-                             &quot;RO&quot;,
-                             &quot;SE&quot;,
-                             &quot;SI&quot;,
-                             &quot;SK&quot;,
-                             &quot;TR&quot;))) %&gt;% select(-year,-geo)
-
-weighted_mean_domestic_TIV_with_labels = cbind(domestic_TIVs_Eurostat,Eurostat_countries_hh_fd_long) %&gt;%
-  group_by(geo,year,coicop) %&gt;%
-  mutate(fd = as.numeric(fd)) %&gt;%
-  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)) %&gt;%
-  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) %&gt;%
-  unique() 
-
-
-
-
-
-ok = join_ala %&gt;% 
-  mutate(year = as.character(year)) %&gt;%
-  left_join(weighted_mean_TIV_with_labels, by = c(&quot;geo&quot;,&quot;year&quot;,&quot;coicop&quot;)) %&gt;%
-  left_join(weighted_mean_europe_TIV_with_labels, by = c(&quot;geo&quot;,&quot;year&quot;,&quot;coicop&quot;)) %&gt;%
-  left_join(weighted_mean_domestic_TIV_with_labels, by = c(&quot;geo&quot;, &quot;year&quot;, &quot;coicop&quot;)) %&gt;%
-  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 &#39;results&#39;
-
-env_ac_pefasu_no_TR = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/env_ac_pefasu_1_Data.csv&quot;)) %&gt;%
-  filter(TIME == 2015) %&gt;%
-  mutate(geo = dplyr::recode(GEO,&quot;Austria&quot; = &quot;AT&quot;, 
-                             &quot;Belgium&quot; = &quot;BE&quot;,
-                             &quot;Cyprus&quot; = &quot;CY&quot;,
-                             &quot;Czechia&quot; = &quot;CZ&quot;,
-                             &quot;Denmark&quot; = &quot;DK&quot;,
-                             &quot;Estonia&quot; = &quot;EE&quot;,
-                             &quot;Finland&quot; = &quot;FI&quot;,
-                             &quot;France&quot; = &quot;FR&quot;,
-                             &quot;Germany (until 1990 former territory of the FRG)&quot; = &quot;DE&quot;,
-                             &quot;Greece&quot; = &quot;EL&quot;,
-                             &quot;Hungary&quot; = &quot;HU&quot;,
-                             &quot;Ireland&quot; = &quot;IE&quot;,
-                             &quot;Italy&quot; = &quot;IT&quot;,
-                             &quot;Latvia&quot; = &quot;LV&quot;,
-                             &quot;Lithuania&quot; = &quot;LT&quot;,
-                             &quot;Luxembourg&quot; = &quot;LU&quot;,
-                             &quot;Malta&quot; = &quot;MT&quot;,
-                             &quot;Netherlands&quot; = &quot;NL&quot;,
-                             &quot;Norway&quot; = &quot;NO&quot;,
-                             &quot;Poland&quot; = &quot;PL&quot;,
-                             &quot;Portugal&quot; = &quot;PT&quot;,
-                             &quot;Romania&quot; = &quot;RO&quot;,
-                             &quot;Slovakia&quot; = &quot;SK&quot;,
-                             &quot;Slovenia&quot; = &quot;SI&quot;,
-                             &quot;Spain&quot; = &quot;ES&quot;,
-                             &quot;Sweden&quot; = &quot;SE&quot;,
-                             &quot;United Kingdom&quot; = &quot;UK&quot;,
-                             &quot;Bulgaria&quot; = &quot;BG&quot;,
-                             &quot;Croatia&quot; = &quot;HR&quot;)) %&gt;%
-  select(NACE_R2,geo,Value) %&gt;%
-  mutate(Value = parse_number(Value),
-         Value = as.numeric(Value)) %&gt;%
-  spread(NACE_R2,Value) %&gt;%
-  clean_names() %&gt;%
-  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) %&gt;%
-  select(geo,HH_HEAT,HH_TRA,HH_OTH) 
-
-
-env_ac_pefasu_TR = env_ac_pefasu_no_TR %&gt;%
-  filter(geo == &quot;BG&quot;) %&gt;%
-  mutate(geo = dplyr::recode(geo,
-                             &quot;BG&quot; = &quot;TR&quot;))
-
-env_ac_pefasu = rbind(env_ac_pefasu_no_TR,env_ac_pefasu_TR) %&gt;%
-  gather(sector,share_of_total_energy,-geo)
-
-env_ac_ainah_r2 = read_csv(paste0(data_dir_income_stratified_footprints, &quot;/data/env_ac_ainah_r2_1_Data.csv&quot;)) %&gt;%
-  filter(TIME == 2015) %&gt;%
-  mutate(geo = dplyr::recode(GEO,&quot;Austria&quot; = &quot;AT&quot;, 
-                             &quot;Belgium&quot; = &quot;BE&quot;,
-                             &quot;Cyprus&quot; = &quot;CY&quot;,
-                             &quot;Czechia&quot; = &quot;CZ&quot;,
-                             &quot;Denmark&quot; = &quot;DK&quot;,
-                             &quot;Estonia&quot; = &quot;EE&quot;,
-                             &quot;Finland&quot; = &quot;FI&quot;,
-                             &quot;France&quot; = &quot;FR&quot;,
-                             &quot;Germany (until 1990 former territory of the FRG)&quot; = &quot;DE&quot;,
-                             &quot;Greece&quot; = &quot;EL&quot;,
-                             &quot;Hungary&quot; = &quot;HU&quot;,
-                             &quot;Ireland&quot; = &quot;IE&quot;,
-                             &quot;Italy&quot; = &quot;IT&quot;,
-                             &quot;Latvia&quot; = &quot;LV&quot;,
-                             &quot;Lithuania&quot; = &quot;LT&quot;,
-                             &quot;Luxembourg&quot; = &quot;LU&quot;,
-                             &quot;Malta&quot; = &quot;MT&quot;,
-                             &quot;Netherlands&quot; = &quot;NL&quot;,
-                             &quot;Norway&quot; = &quot;NO&quot;,
-                             &quot;Poland&quot; = &quot;PL&quot;,
-                             &quot;Portugal&quot; = &quot;PT&quot;,
-                             &quot;Romania&quot; = &quot;RO&quot;,
-                             &quot;Slovakia&quot; = &quot;SK&quot;,
-                             &quot;Slovenia&quot; = &quot;SI&quot;,
-                             &quot;Spain&quot; = &quot;ES&quot;,
-                             &quot;Sweden&quot; = &quot;SE&quot;,
-                             &quot;Turkey&quot; = &quot;TR&quot;,
-                             &quot;United Kingdom&quot; = &quot;UK&quot;,
-                             &quot;Bulgaria&quot; = &quot;BG&quot;,
-                             &quot;Croatia&quot; = &quot;HR&quot;)) %&gt;%
-  select(NACE_R2,AIRPOL,geo,Value) %&gt;%
-  mutate(Value = parse_number(Value),
-         Value = as.numeric(Value)) %&gt;%
-  spread(NACE_R2,Value) %&gt;%
-  clean_names() %&gt;%
-  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) %&gt;%
-  select(geo,airpol,HH_HEAT,HH_TRA,HH_OTH) 
-
-
-env_ac_ainah_r2_co2 = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Carbon dioxide&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_co2,-geo)
-
-env_ac_ainah_r2_ch4 = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Methane&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_ch4,-geo)
-
-env_ac_ainah_r2_n2o = env_ac_ainah_r2 %&gt;%
-  filter(airpol == &quot;Nitrous oxide&quot;) %&gt;%
-  select(-airpol) %&gt;%
-  gather(sector,share_of_total_n2o,-geo)
-
-direct_FD_fp_long = national_fp %&gt;%
-  filter(fd_category == &quot;Final consumption expenditure by households&quot;,
-         geo %in% c(&quot;AT&quot;,
-                    &quot;BE&quot;, &quot;BG&quot;, &quot;CY&quot;, &quot;CZ&quot;,
-                    &quot;DE&quot; , &quot;DK&quot; , &quot;EE&quot; , 
-                    &quot;ES&quot; , &quot;FI&quot; , &quot;FR&quot; , 
-                    &quot;UK&quot;, &quot;EL&quot;, &quot;HR&quot; ,
-                    &quot;HU&quot; , &quot;IE&quot; , &quot;IT&quot; ,
-                    &quot;LT&quot; , &quot;LU&quot; , &quot;LV&quot; ,
-                    &quot;MT&quot; , &quot;NL&quot; , &quot;PL&quot; ,
-                    &quot;PT&quot; , &quot;TR&quot; , &quot;SK&quot; ,
-                    &quot;SI&quot; , &quot;SE&quot; , &quot;RO&quot; ,
-                    &quot;NO&quot;)) %&gt;%
-  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) %&gt;%   
-  slice(rep(1:n(), each = 3)) 
-
-sector = rep(c(&quot;HH_HEAT&quot;,&quot;HH_TRA&quot;,&quot;HH_OTH&quot;), nrow(direct_FD_fp_long)/3) 
-
-direct_FD_fp_long_disagg = cbind(sector,direct_FD_fp_long) %&gt;%
-  mutate(coicop = ifelse(sector == &quot;HH_TRA&quot;,&quot;CP072&quot;,
-                         ifelse(sector == &quot;HH_HEAT&quot;,&quot;CP045&quot;,&quot;CP05&quot;)), 
-         five_sectors = ifelse(sector == &quot;HH_TRA&quot;, &quot;transport&quot;,
-                               ifelse(sector == &quot;HH_HEAT&quot;, &quot;shelter&quot;, &quot;manufactured goods&quot;))) %&gt;%
-  left_join(env_ac_ainah_r2_co2, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_ainah_r2_ch4, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_ainah_r2_n2o, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  left_join(env_ac_pefasu, by = c(&quot;geo&quot;,&quot;sector&quot;)) %&gt;%
-  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) %&gt;%
-  left_join(shares, by = c(&quot;year&quot;,&quot;geo&quot;,&quot;coicop&quot;)) %&gt;%
-  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) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_co2) %&gt;%
-  spread(quintile,disaggregated_direct_FD_co2) %&gt;%
-  rename(q1_co2 = QUINTILE1,
-         q2_co2 = QUINTILE2,
-         q3_co2 = QUINTILE3,
-         q4_co2 = QUINTILE4,
-         q5_co2 = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_ch4) %&gt;%
-  spread(quintile,disaggregated_direct_FD_ch4) %&gt;%
-  rename(q1_ch4 = QUINTILE1,
-         q2_ch4 = QUINTILE2,
-         q3_ch4 = QUINTILE3,
-         q4_ch4 = QUINTILE4,
-         q5_ch4 = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_n2o) %&gt;%
-  spread(quintile,disaggregated_direct_FD_n2o) %&gt;%
-  rename(q1_n2o = QUINTILE1,
-         q2_n2o = QUINTILE2,
-         q3_n2o = QUINTILE3,
-         q4_n2o = QUINTILE4,
-         q5_n2o = QUINTILE5) %&gt;%
-  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 %&gt;%
-  select(year,geo,sector,quintile,coicop,five_sectors,disaggregated_direct_FD_energy) %&gt;%
-  spread(quintile,disaggregated_direct_FD_energy) %&gt;%
-  rename(q1_energy = QUINTILE1,
-         q2_energy = QUINTILE2,
-         q3_energy = QUINTILE3,
-         q4_energy = QUINTILE4,
-         q5_energy = QUINTILE5) %&gt;%
-  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 %&gt;%
-  left_join(direct_FD_ch4, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                  &quot;sector&quot;,&quot;coicop&quot;,
-                                  &quot;five_sectors&quot;)) %&gt;%
-  left_join(direct_FD_n2o, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                  &quot;sector&quot;,&quot;coicop&quot;,
-                                  &quot;five_sectors&quot;)) %&gt;%
-  left_join(direct_FD_energy, by = c(&quot;year&quot;,&quot;geo&quot;,
-                                     &quot;sector&quot;,&quot;coicop&quot;,
-                                     &quot;five_sectors&quot;)) %&gt;%
-  mutate(country_of_production = geo) %&gt;%
-  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) %&gt;%
-  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 %&gt;%
-  clean_names() %&gt;%
-  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(&quot;q1_co2&quot;, &quot;q2_co2&quot;, &quot;q3_co2&quot;, &quot;q4_co2&quot;, &quot;q5_co2&quot;)
-tmp_co2 = direct_FD_fp_wide_all %&gt;%
-  select(year, geo, coicop, cols_co2) %&gt;%
-  pivot_longer(cols = cols_co2,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2 domestic and pivot long
-cols_co2_domestic = c(&quot;q1_co2_domestic&quot;, &quot;q2_co2_domestic&quot;, &quot;q3_co2_domestic&quot;, &quot;q4_co2_domestic&quot;, &quot;q5_co2_domestic&quot;)
-tmp_co2_domestic = direct_FD_fp_wide_all %&gt;%
-  select(year, geo, coicop, cols_co2_domestic) %&gt;%
-  pivot_longer(cols = cols_co2_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2_domestic_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2eq and pivot long
-cols_co2eq = c(&quot;q1_co2eq&quot;, &quot;q2_co2eq&quot;, &quot;q3_co2eq&quot;, &quot;q4_co2eq&quot;, &quot;q5_co2eq&quot;)
-tmp_co2eq = direct_FD_fp_wide_all %&gt;%
-  select(year, geo, coicop, cols_co2eq) %&gt;%
-  pivot_longer(cols = cols_co2eq,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract co2eq domestic and pivot long
-cols_co2eq_domestic = c(&quot;q1_co2eq_domestic&quot;, &quot;q2_co2eq_domestic&quot;, &quot;q3_co2eq_domestic&quot;, &quot;q4_co2eq_domestic&quot;, &quot;q5_co2eq_domestic&quot;)
-tmp_co2eq_domestic = direct_FD_fp_wide_all %&gt;%
-  select(year, geo, coicop, cols_co2eq_domestic) %&gt;%
-  pivot_longer(cols = cols_co2eq_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;co2eq_domestic_kg&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy use and pivot long
-cols_energy = c(&quot;q1_energy&quot;,&quot;q2_energy&quot;,&quot;q3_energy&quot;,&quot;q4_energy&quot;,&quot;q5_energy&quot;)
-tmp_energy = direct_FD_fp_wide_all %&gt;%
-  select(year, geo, coicop, cols_energy) %&gt;%
-  pivot_longer(cols = cols_energy,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-## extract energy domestic and pivot long
-cols_energy_domestic = c(&quot;q1_energy_domestic&quot;,&quot;q2_energy_domestic&quot;,&quot;q3_energy_domestic&quot;,&quot;q4_energy_domestic&quot;,&quot;q5_energy_domestic&quot;)
-tmp_energy_domestic = direct_FD_fp_wide_all %&gt;%
-  select(year, geo, coicop, cols_energy_domestic) %&gt;%
-  pivot_longer(cols = cols_energy_domestic,
-               names_to = &quot;quintile&quot;,
-               values_to = &quot;energy_use_domestic_TJ&quot;) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile)
-
-direct_FD_fp_wide_recombined = tmp_co2 %&gt;%
-  left_join(tmp_co2_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;coicop&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;coicop&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_co2eq_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;coicop&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;coicop&quot;, &quot;quint&quot;)) %&gt;%
-  left_join(tmp_energy_domestic, by=c(&quot;year&quot;, &quot;geo&quot;, &quot;coicop&quot;, &quot;quint&quot;)) %&gt;%
-  clean_names() %&gt;%
-  mutate(year = as.numeric(year))
-
-
-
-# something is wrong with &#39;bah&#39; (don&#39;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 %&gt;% 
-  filter(!(geo %in% c(&quot;EA&quot;,&quot;EA12&quot;,&quot;EA13&quot;,&quot;EA17&quot;,
-                      &quot;EA18&quot;,&quot;EA19&quot;,&quot;EEA28&quot;,&quot;EEA30_2007&quot;,
-                      &quot;EFTA&quot;,&quot;EU15&quot;,&quot;EU25&quot;,
-                      &quot;EU27_2007&quot;, &quot;EU27_2020&quot;,
-                      &quot;EU28&quot;,&quot;XK&quot;, &quot;RS&quot;, 
-                      &quot;MK&quot;, &quot;ME&quot;)),
-         !(quintile %in% c(&quot;TOTAL&quot;,&quot;UNK&quot;)),
-         !(year %in% c(1988,1994,1999))) %&gt;%
-  group_by(geo,quintile,year,coicop) %&gt;%
-  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)) %&gt;% 
-  ungroup() %&gt;%
-  mutate(year = as.numeric(year)) %&gt;%
-  na.omit() 
-
-results_formatted = results %&gt;%
-  clean_names() %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  select(-quintile) %&gt;%
-  filter(coicop %in% c(&quot;CP011&quot;,
-                       &quot;CP012&quot;,
-                       &quot;CP02&quot;,
-                       &quot;CP03&quot;,
-                       &quot;rent&quot;,
-                       &quot;CP043&quot;,
-                       &quot;CP044&quot;,
-                       &quot;CP045&quot;,
-                       &quot;CP05&quot;,
-                       &quot;CP06&quot;,
-                       &quot;CP071&quot;,
-                       &quot;CP072&quot;,
-                       &quot;CP073&quot;,
-                       &quot;CP08&quot;,
-                       &quot;CP09&quot;,
-                       &quot;CP10&quot;,
-                       &quot;CP11&quot;,
-                       &quot;CP12&quot;))
-
-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, &quot;/results_formatted_method2_ixi_pps_hh_no_rent.csv&quot;))</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(&quot;pacman&quot;)) install.packages(&quot;pacman&quot;)
-pacman::p_load(tidyverse,
-               janitor,
-               here,
-               wbstats,
-               ISOcodes,
-               viridis,
-               imputeTS,
-               hrbrthemes,
-               wesanderson,
-               glue)
-
-target_eu_ntiles = 10
-
-source(here(&quot;code&quot;, &quot;helper_functions.R&quot;))
-
-
-# 1) load MRIO result file
-dat_results_raw = read_rds(here(&quot;data&quot;, &quot;results_formatted_method1_ixi_pps_hh_no_rent.rds&quot;)) %&gt;%
-  ungroup() %&gt;%
-  mutate(year= strtoi(year)) %&gt;%
-  rename(iso2 = geo)
-
-# get iso3 country codes to join with hh data
-country_codes = ISOcodes::ISO_3166_1 %&gt;%
-  select(iso2 = Alpha_2, iso3 = Alpha_3) %&gt;%
-  # resolve inconsistency between Eurostat and ISO for Greece and UK/Great Britain
-  mutate(iso2 = if_else(iso2==&quot;GR&quot;, &quot;EL&quot;, iso2)) %&gt;%
-  mutate(iso2 = if_else(iso2==&quot;GB&quot;, &quot;UK&quot;, iso2))
-
-# 2) load Eurostat household data - should show how I get to &#39;total_private_households.csv&#39; - see code chunk in SI - move to here. 
-hh_data = read_csv(here(&quot;data&quot;, &quot;total_private_households.csv&quot;)) %&gt;%
-  mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %&gt;%
-  rename(iso2 = geo) %&gt;%
-  group_by(iso2) %&gt;%
-  # impute households with next available neighbour
-  mutate(hh = na_locf(total_private_households)) %&gt;%
-  left_join(country_codes, by=&quot;iso2&quot;) %&gt;%
-  select(-total_private_households)
-
-#3) Eurostat mean expenditures per household income quintile per household and per adult equivalent
-df_expenditure_long = read_csv(here(&quot;data&quot;,
-                                    &quot;mean_expenditure_by_quintile_long.csv&quot;),
-                               na = &quot;:&quot;) %&gt;%
-  #filter(year &gt;=2010, geo != &quot;IT&quot;) %&gt;%
-  #filter(year &gt;=2005, geo != &quot;IT&quot;) %&gt;%
-  #decide here
-  filter(year &gt;=2005) %&gt;%
-  mutate(imputed = if_else(is.na(mean_expenditure), TRUE, FALSE)) %&gt;%
-  group_by(geo,unit,quintile) %&gt;%
-  mutate(value = na_locf(mean_expenditure)) %&gt;%
-  select(-mean_expenditure) %&gt;% 
-  ungroup()
-
-
-# df_expenditure_2005 = df_expenditure_long %&gt;%
-#   filter(year == 2010) %&gt;%
-#   mutate(year = 2005,
-#          imputed = TRUE)
-#   
-# df_expenditure_long = df_expenditure_long %&gt;%
-#   bind_rows(df_expenditure_2005) 
-
-## Calculate adult equivalents per household
-df_adult_e_p_hh = df_expenditure_long %&gt;%
-  rename(iso2 = geo) %&gt;%
-  pivot_wider(id_cols = c(iso2, year, quintile, imputed), 
-              names_from = unit, 
-              values_from = value) %&gt;%
-  clean_names() %&gt;%
-  mutate(adult_e_p_hh = pps_hh/pps_ae) %&gt;%
-  left_join(country_codes, by=&quot;iso2&quot;) %&gt;%
-  mutate(iso3 = if_else(iso2 == &quot;XK&quot;, &quot;XKX&quot;, iso3),
-         quint = parse_number(quintile))
-
-
-# add quintile population data
-mrio_results_with_adult_eq_all = dat_results_raw %&gt;%
-  filter(year %in% c(2005, 2010, 2015)) %&gt;%
-  left_join(hh_data, by=c(&quot;iso2&quot;, &quot;year&quot;)) %&gt;%
-  mutate(hh_quintile = hh/5) %&gt;% # population per country quinitle
-  select(-hh) %&gt;%
-  rename(hh_imputed = imputed) %&gt;%
-  left_join(df_adult_e_p_hh %&gt;%
-              select(iso2, year, quint, imputed_ae = imputed, adult_e_p_hh), 
-            by=c(&quot;iso2&quot;, &quot;year&quot;, &quot;quint&quot;)) %&gt;%
-  mutate(ae_quintile = hh_quintile * adult_e_p_hh) %&gt;%
-  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 %&gt;%
-  group_by(year, iso2) %&gt;%
-  summarise(co2_kg = sum(co2_kg)) %&gt;%
-  ungroup() %&gt;%
-  filter(co2_kg&gt;0) %&gt;%
-  select(iso2, year, co2_kg) %&gt;%
-  pivot_wider(id_cols = c(iso2), names_from = year, values_from = co2_kg) %&gt;%
-  drop_na() %&gt;%
-  select(iso2) %&gt;%
-  pull()
-
-
-hh_data %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-ggplot(aes(x=year, y=hh*0.000001)) +
-  geom_line() +
-  geom_point(data=hh_data %&gt;% 
-               filter(iso2 %in% complete_countries,
-                      year&lt;=2015, 
-                      year&gt;=2005,
-                      imputed), color=&quot;red&quot;) +
-  theme_ipsum() +
-  scale_x_continuous(labels = scales::label_number(accuracy = 1, big.mark = &quot;&quot;)) +
-  labs(x=&quot;&quot;, y=&quot;Total number of households (mio)&quot;) +
-  facet_wrap(~iso3, scales=&quot;free_y&quot;, ncol = 4) +
-  theme(legend.position = &quot;bottom&quot;, 
-        axis.text.x = element_text(angle = 90))
-
-#ggsave(here(&quot;figures&quot;, &quot;household_size.png&quot;), plot = p, width = 8, height = 14)
-
-pal &lt;- wes_palette(&quot;Cavalcanti1&quot;, 5, type = &quot;discrete&quot;)
-pal = pal[c(1,2,5)]
-
-df_adult_e_p_hh %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  ggplot(aes(x=quint, y=adult_e_p_hh, color=factor(year))) +
-  geom_line(alpha=0.5) +
-  theme_ipsum() +
-  scale_color_manual(name = &quot;Year&quot;, values = pal) +
-  labs(x=&quot;&quot;, y=&quot;Adult equivivalents per household&quot;) +
-  facet_wrap(~iso3, ncol = 4) +
-  theme(legend.position = &quot;bottom&quot;, 
-        axis.text.x = element_text(angle = 90))
-
-#ggsave(here(&quot;figures&quot;, &quot;adult_eq_per_household.png&quot;), plot = p, width = 8, height = 14)
-
-df_adult_e_p_hh %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  write_csv(here(&quot;data&quot;, &quot;adult_eq_per_household.csv&quot;))
-
-
-# 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 &lt;- function(pyear, pquantile_count=10) {
-  
-  country_data_annual_sorted = summary_country_fd %&gt;%
-    ungroup() %&gt;%
-    filter(year==pyear) %&gt;%
-    arrange(fd_pae_e) %&gt;%
-    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 %&gt;%
-    filter(year==1)
-  
-  # store quantile split values
-  eu_quantile_boundaries = data.frame(euro_q_rank = 1:pquantile_count, p = 0)
-  
-  ## can&#39;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[&quot;ae_quintile&quot;] + eu_ae_current &lt;= eu_decile_adult_eq) {
-      eu_ae_current = eu_ae_current + row[&quot;ae_quintile&quot;]
-      country_data_annual_sorted[row_idx, &quot;eu_q_rank&quot;] = 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, &quot;eu_q_rank&quot;] = euro_q_rank_current
-      new_row[1, &quot;ae_quintile&quot;] = ae_diff
-      ## record eu quantile boundary
-      eu_quantile_boundaries[eu_quantile_boundaries$euro_q_rank==euro_q_rank_current, &quot;p&quot;] =
-        country_data_annual_sorted[row_idx, &quot;fd_pae_e&quot;]
-      ## put first part of population in overflow dataframe
-      additional_rows = additional_rows %&gt;%
-        bind_rows(new_row)
-      ## classify rest of country quinitle population to next euro quantile
-      country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;] = 
-        country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;] - (ae_diff+0.0001)
-      euro_q_rank_current = euro_q_rank_current + 1
-      country_data_annual_sorted[row_idx, &quot;eu_q_rank&quot;] = euro_q_rank_current
-      eu_ae_current = country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;]
-      
-    }
-  }
-  
-  country_data_eu_quantiles = country_data_annual_sorted %&gt;%
-  bind_rows(additional_rows) %&gt;%
-  arrange(fd_pae_e, eu_q_rank) %&gt;%
-  mutate(idx = 1:n())
-
-  #ad zeroth and nth quantile (min and max)
-  eu_quantile_boundaries[pquantile_count, &quot;p&quot;] = max(country_data_eu_quantiles$fd_pae_e)
-  #tmp = data.frame(euro_q_rank = 0, p = min(country_data_eu_quantiles$fd_pae_e)) %&gt;%
-  #  bind_rows(eu_quantile_boundaries) 
-  
-  
-  list(&quot;df_q_data&quot; = country_data_eu_quantiles, &quot;df_q_boundaries&quot; = eu_quantile_boundaries)
-}
-
-# maps MRIO results to EU ntile ranks, returns mapping and ntile EU boundaries
-map_mrio_results_to_eu_ntiles &lt;- 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 %&gt;%
-    group_by(sector_id) %&gt;%#
-    summarise(sector_agg_id = first(sector_agg_id)) %&gt;%
-    ungroup()
-  
-  df_mapped_data = mrio_results_with_adult_eq %&gt;%
-    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) %&gt;%
-    filter(year==pyear) %&gt;%
-    # 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) %&gt;%
-    # 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)) %&gt;%
-    full_join(df_eu_ntiles_data %&gt;%
-                rename(fd_pae_e_quint_tmp = fd_pae_e), by=c(&quot;iso2&quot;, &quot;quint&quot;)) %&gt;%
-    rename(adult_eq = ae_quintile) %&gt;% # 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
-           ) %&gt;%
-    left_join(sector_mapping, by=&quot;sector_id&quot;)
-  
-  list(&quot;df_mapped_data&quot; = df_mapped_data, &quot;df_ntile_boundaries&quot; = 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 %&gt;%
-  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 %&gt;%
-  group_by(iso2, year, quint) %&gt;%
-  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 %&gt;%
-  group_by(iso2, year, quint) %&gt;%
-  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 %&gt;%
-  bind_rows(df_mapped_result_2010_data) %&gt;%
-  bind_rows(df_mapped_result_2015_data)
-
-write_csv(df_mapped_result_data, 
-          here(paste0(&quot;data/mrio_results_eu_ntile_mapped_n_&quot;, target_eu_ntiles, &quot;.csv&quot;)))
-
-df_mapped_result_ntiles = 
-  df_mapped_result_2005_ntiles %&gt;% mutate(year=2005) %&gt;%
-  bind_rows(df_mapped_result_2010_ntiles %&gt;% mutate(year=2010)) %&gt;%
-  bind_rows(df_mapped_result_2015_ntiles %&gt;% mutate(year=2015))
-
-write_csv(df_mapped_result_ntiles, 
-          here(paste0(&quot;data/eu_ntiles_n_&quot;, target_eu_ntiles, &quot;.csv&quot;)))
-
-######
-
-knitr::opts_chunk$set(echo = FALSE, message=FALSE)
-
-if (!require(&quot;pacman&quot;)) install.packages(&quot;pacman&quot;)
-pacman::p_load(tidyverse,
-               janitor,
-               here,
-               wbstats,
-               ISOcodes,
-               viridis,
-               imputeTS,
-               hrbrthemes,
-               wesanderson,
-               glue)
-
-target_eu_ntiles = 10
-
-source(here(&quot;code&quot;, &quot;helper_functions.R&quot;))
-
-dat_results_raw = read_rds(here(&quot;data&quot;, &quot;results_formatted_method1_pxp_pps_hh_no_rent.rds&quot;)) %&gt;%
-  ungroup() %&gt;%
-  mutate(year= strtoi(year)) %&gt;%
-  rename(iso2 = geo)
-
-# get iso3 country codes to join with hh data
-country_codes = ISOcodes::ISO_3166_1 %&gt;%
-  select(iso2 = Alpha_2, iso3 = Alpha_3) %&gt;%
-  # resolve inconsistency between Eurostat and ISO for Greece and UK/Great Britain
-  mutate(iso2 = if_else(iso2==&quot;GR&quot;, &quot;EL&quot;, iso2)) %&gt;%
-  mutate(iso2 = if_else(iso2==&quot;GB&quot;, &quot;UK&quot;, iso2))
-
-# 2) load Eurostat household data
-hh_data = read_csv(here(&quot;data&quot;, &quot;total_private_households.csv&quot;)) %&gt;%
-  mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %&gt;%
-  rename(iso2 = geo) %&gt;%
-  group_by(iso2) %&gt;%
-  # impute households with next available neighbour
-  mutate(hh = na_locf(total_private_households)) %&gt;%
-  left_join(country_codes, by=&quot;iso2&quot;) %&gt;%
-  select(-total_private_households)
-
-#3) Eurostat mean expenditures per household income quintile per household and per adult equivalent
-df_expenditure_long = read_csv(here(&quot;data&quot;,
-                                    &quot;mean_expenditure_by_quintile_long.csv&quot;),
-                               na = &quot;:&quot;) %&gt;%
-  #filter(year &gt;=2010, geo != &quot;IT&quot;) %&gt;%
-  #filter(year &gt;=2005, geo != &quot;IT&quot;) %&gt;%
-  #decide here
-  filter(year &gt;=2005) %&gt;%
-  mutate(imputed = if_else(is.na(mean_expenditure), TRUE, FALSE)) %&gt;%
-  group_by(geo,unit,quintile) %&gt;%
-  mutate(value = na_locf(mean_expenditure)) %&gt;%
-  select(-mean_expenditure) %&gt;% 
-  ungroup()
-
-# df_expenditure_2005 = df_expenditure_long %&gt;%
-#   filter(year == 2010) %&gt;%
-#   mutate(year = 2005,
-#          imputed = TRUE)
-#   
-# df_expenditure_long = df_expenditure_long %&gt;%
-#   bind_rows(df_expenditure_2005) 
-
-## Calculate adult equivalents per household
-df_adult_e_p_hh = df_expenditure_long %&gt;%
-  rename(iso2 = geo) %&gt;%
-  pivot_wider(id_cols = c(iso2, year, quintile, imputed), 
-              names_from = unit, 
-              values_from = value) %&gt;%
-  clean_names() %&gt;%
-  mutate(adult_e_p_hh = pps_hh/pps_ae) %&gt;%
-  left_join(country_codes, by=&quot;iso2&quot;) %&gt;%
-  mutate(iso3 = if_else(iso2 == &quot;XK&quot;, &quot;XKX&quot;, iso3),
-         quint = parse_number(quintile))
-
-
-# add quintile population data
-mrio_results_with_adult_eq_all = dat_results_raw %&gt;%
-  filter(year %in% c(2005, 2010, 2015)) %&gt;%
-  left_join(hh_data, by=c(&quot;iso2&quot;, &quot;year&quot;)) %&gt;%
-  mutate(hh_quintile = hh/5) %&gt;% # population per country quinitle
-  select(-hh) %&gt;%
-  rename(hh_imputed = imputed) %&gt;%
-  left_join(df_adult_e_p_hh %&gt;%
-              select(iso2, year, quint, imputed_ae = imputed, adult_e_p_hh), 
-            by=c(&quot;iso2&quot;, &quot;year&quot;, &quot;quint&quot;)) %&gt;%
-  mutate(ae_quintile = hh_quintile * adult_e_p_hh) %&gt;%
-  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 %&gt;%
-  group_by(year, iso2) %&gt;%
-  summarise(co2_kg = sum(co2_kg)) %&gt;%
-  ungroup() %&gt;%
-  filter(co2_kg&gt;0) %&gt;%
-  select(iso2, year, co2_kg) %&gt;%
-  pivot_wider(id_cols = c(iso2), names_from = year, values_from = co2_kg) %&gt;%
-  drop_na() %&gt;%
-  select(iso2) %&gt;%
-  pull()
-
-hh_data %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-ggplot(aes(x=year, y=hh*0.000001)) +
-  geom_line() +
-  geom_point(data=hh_data %&gt;% 
-               filter(iso2 %in% complete_countries,
-                      year&lt;=2015, 
-                      year&gt;=2005,
-                      imputed), color=&quot;red&quot;) +
-  theme_ipsum() +
-  scale_x_continuous(labels = scales::label_number(accuracy = 1, big.mark = &quot;&quot;)) +
-  labs(x=&quot;&quot;, y=&quot;Total number of households (mio)&quot;) +
-  facet_wrap(~iso3, scales=&quot;free_y&quot;, ncol = 4) +
-  theme(legend.position = &quot;bottom&quot;, 
-        axis.text.x = element_text(angle = 90))
-
-#ggsave(here(&quot;figures&quot;, &quot;household_size.png&quot;), plot = p, width = 8, height = 14)
-
-pal &lt;- wes_palette(&quot;Cavalcanti1&quot;, 5, type = &quot;discrete&quot;)
-pal = pal[c(1,2,5)]
-
-df_adult_e_p_hh %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  ggplot(aes(x=quint, y=adult_e_p_hh, color=factor(year))) +
-  geom_line(alpha=0.5) +
-  theme_ipsum() +
-  scale_color_manual(name = &quot;Year&quot;, values = pal) +
-  labs(x=&quot;&quot;, y=&quot;Adult equivivalents per household&quot;) +
-  facet_wrap(~iso3, ncol = 4) +
-  theme(legend.position = &quot;bottom&quot;, 
-        axis.text.x = element_text(angle = 90))
-
-#ggsave(here(&quot;figures&quot;, &quot;adult_eq_per_household.png&quot;), plot = p, width = 8, height = 14)
-
-df_adult_e_p_hh %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  write_csv(here(&quot;data&quot;, &quot;adult_eq_per_household.csv&quot;))
-
-# 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 &lt;- function(pyear, pquantile_count=10) {
-  
-  country_data_annual_sorted = summary_country_fd %&gt;%
-    ungroup() %&gt;%
-    filter(year==pyear) %&gt;%
-    arrange(fd_pae_e) %&gt;%
-    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 %&gt;%
-    filter(year==1)
-  
-  # store quantile split values
-  eu_quantile_boundaries = data.frame(euro_q_rank = 1:pquantile_count, p = 0)
-  
-  ## can&#39;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[&quot;ae_quintile&quot;] + eu_ae_current &lt;= eu_decile_adult_eq) {
-      eu_ae_current = eu_ae_current + row[&quot;ae_quintile&quot;]
-      country_data_annual_sorted[row_idx, &quot;eu_q_rank&quot;] = 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, &quot;eu_q_rank&quot;] = euro_q_rank_current
-      new_row[1, &quot;ae_quintile&quot;] = ae_diff
-      ## record eu quantile boundary
-      eu_quantile_boundaries[eu_quantile_boundaries$euro_q_rank==euro_q_rank_current, &quot;p&quot;] =
-        country_data_annual_sorted[row_idx, &quot;fd_pae_e&quot;]
-      ## put first part of population in overflow dataframe
-      additional_rows = additional_rows %&gt;%
-        bind_rows(new_row)
-      ## classify rest of country quinitle population to next euro quantile
-      country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;] = 
-        country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;] - (ae_diff+0.0001)
-      euro_q_rank_current = euro_q_rank_current + 1
-      country_data_annual_sorted[row_idx, &quot;eu_q_rank&quot;] = euro_q_rank_current
-      eu_ae_current = country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;]
-      
-    }
-  }
-  
-  country_data_eu_quantiles = country_data_annual_sorted %&gt;%
-  bind_rows(additional_rows) %&gt;%
-  arrange(fd_pae_e, eu_q_rank) %&gt;%
-  mutate(idx = 1:n())
-
-  #ad zeroth and nth quantile (min and max)
-  eu_quantile_boundaries[pquantile_count, &quot;p&quot;] = max(country_data_eu_quantiles$fd_pae_e)
-  #tmp = data.frame(euro_q_rank = 0, p = min(country_data_eu_quantiles$fd_pae_e)) %&gt;%
-  #  bind_rows(eu_quantile_boundaries) 
-  
-  
-  list(&quot;df_q_data&quot; = country_data_eu_quantiles, &quot;df_q_boundaries&quot; = eu_quantile_boundaries)
-}
-
-# maps MRIO results to EU ntile ranks, returns mapping and ntile EU boundaries
-map_mrio_results_to_eu_ntiles &lt;- 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 %&gt;%
-    group_by(sector_id) %&gt;%#
-    summarise(sector_agg_id = first(sector_agg_id)) %&gt;%
-    ungroup()
-  
-  df_mapped_data = mrio_results_with_adult_eq %&gt;%
-    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) %&gt;%
-    filter(year==pyear) %&gt;%
-    # 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) %&gt;%
-    # 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)) %&gt;%
-    full_join(df_eu_ntiles_data %&gt;%
-                rename(fd_pae_e_quint_tmp = fd_pae_e), by=c(&quot;iso2&quot;, &quot;quint&quot;)) %&gt;%
-    rename(adult_eq = ae_quintile) %&gt;% # 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
-           ) %&gt;%
-    left_join(sector_mapping, by=&quot;sector_id&quot;)
-  
-  list(&quot;df_mapped_data&quot; = df_mapped_data, &quot;df_ntile_boundaries&quot; = 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 %&gt;%
-  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 %&gt;%
-  group_by(iso2, year, quint) %&gt;%
-  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 %&gt;%
-  group_by(iso2, year, quint) %&gt;%
-  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 %&gt;%
-  bind_rows(df_mapped_result_2010_data) #%&gt;%
-  #bind_rows(df_mapped_result_2015_data)
-
-write_csv(df_mapped_result_data, 
-          here(paste0(&quot;data/mrio_results_eu_ntile_mapped_n_&quot;, target_eu_ntiles, &quot;_pxp.csv&quot;)))
-
-df_mapped_result_ntiles = 
-  df_mapped_result_2005_ntiles %&gt;% mutate(year=2005) %&gt;%
-  bind_rows(df_mapped_result_2010_ntiles %&gt;% mutate(year=2010)) #%&gt;%
-  #bind_rows(df_mapped_result_2015_ntiles %&gt;% mutate(year=2015))
-
-write_csv(df_mapped_result_ntiles, 
-          here(paste0(&quot;data/eu_ntiles_n_&quot;, target_eu_ntiles, &quot;_pxp.csv&quot;)))
-
-######
-
-knitr::opts_chunk$set(echo = FALSE, message=FALSE)
-
-if (!require(&quot;pacman&quot;)) install.packages(&quot;pacman&quot;)
-pacman::p_load(tidyverse,
-               janitor,
-               here,
-               wbstats,
-               ISOcodes,
-               viridis,
-               imputeTS,
-               hrbrthemes,
-               wesanderson,
-               glue)
-
-target_eu_ntiles = 10
-
-source(here(&quot;code&quot;, &quot;helper_functions.R&quot;))
-
-# 1) load MRIO result file
-dat_results_raw = read_rds(here(&quot;data&quot;, &quot;results_formatted_method2_ixi_pps_hh_no_rent.rds&quot;)) %&gt;%
-  ungroup() %&gt;%
-  mutate(year= strtoi(year)) %&gt;%
-  rename(iso2 = geo)
-
-# get iso3 country codes to join with hh data
-country_codes = ISOcodes::ISO_3166_1 %&gt;%
-  select(iso2 = Alpha_2, iso3 = Alpha_3) %&gt;%
-  # resolve inconsistency between Eurostat and ISO for Greece and UK/Great Britain
-  mutate(iso2 = if_else(iso2==&quot;GR&quot;, &quot;EL&quot;, iso2)) %&gt;%
-  mutate(iso2 = if_else(iso2==&quot;GB&quot;, &quot;UK&quot;, iso2))
-
-# 2) load Eurostat household data
-hh_data = read_csv(here(&quot;data&quot;, &quot;total_private_households.csv&quot;)) %&gt;%
-  mutate(imputed = if_else(is.na(total_private_households), TRUE, FALSE)) %&gt;%
-  rename(iso2 = geo) %&gt;%
-  group_by(iso2) %&gt;%
-  # impute households with next available neighbour
-  mutate(hh = na_locf(total_private_households)) %&gt;%
-  left_join(country_codes, by=&quot;iso2&quot;) %&gt;%
-  select(-total_private_households)
-
-#3) Eurostat mean expenditures per household income quintile per household and per adult equivalent
-df_expenditure_long = read_csv(here(&quot;data&quot;,
-                                    &quot;mean_expenditure_by_quintile_long.csv&quot;),
-                               na = &quot;:&quot;) %&gt;%
-  #filter(year &gt;=2010, geo != &quot;IT&quot;) %&gt;%
-  #filter(year &gt;=2005, geo != &quot;IT&quot;) %&gt;%
-  #decide here
-  filter(year &gt;=2005) %&gt;%
-  mutate(imputed = if_else(is.na(mean_expenditure), TRUE, FALSE)) %&gt;%
-  group_by(geo,unit,quintile) %&gt;%
-  mutate(value = na_locf(mean_expenditure)) %&gt;%
-  select(-mean_expenditure) %&gt;% 
-  ungroup()
-
-# df_expenditure_2005 = df_expenditure_long %&gt;%
-#   filter(year == 2010) %&gt;%
-#   mutate(year = 2005,
-#          imputed = TRUE)
-#   
-# df_expenditure_long = df_expenditure_long %&gt;%
-#   bind_rows(df_expenditure_2005) 
-
-## Calculate adult equivalents per household
-df_adult_e_p_hh = df_expenditure_long %&gt;%
-  rename(iso2 = geo) %&gt;%
-  pivot_wider(id_cols = c(iso2, year, quintile, imputed), 
-              names_from = unit, 
-              values_from = value) %&gt;%
-  clean_names() %&gt;%
-  mutate(adult_e_p_hh = pps_hh/pps_ae) %&gt;%
-  left_join(country_codes, by=&quot;iso2&quot;) %&gt;%
-  mutate(iso3 = if_else(iso2 == &quot;XK&quot;, &quot;XKX&quot;, iso3),
-         quint = parse_number(quintile))
-
-
-# add quintile population data
-mrio_results_with_adult_eq_all = dat_results_raw %&gt;%
-  filter(year %in% c(2005, 2010, 2015)) %&gt;%
-  left_join(hh_data, by=c(&quot;iso2&quot;, &quot;year&quot;)) %&gt;%
-  mutate(hh_quintile = hh/5) %&gt;% # population per country quinitle
-  select(-hh) %&gt;%
-  rename(hh_imputed = imputed) %&gt;%
-  left_join(df_adult_e_p_hh %&gt;%
-              select(iso2, year, quint, imputed_ae = imputed, adult_e_p_hh), 
-            by=c(&quot;iso2&quot;, &quot;year&quot;, &quot;quint&quot;)) %&gt;%
-  mutate(ae_quintile = hh_quintile * adult_e_p_hh) %&gt;%
-  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 %&gt;%
-  group_by(year, iso2) %&gt;%
-  summarise(co2_kg = sum(co2_kg)) %&gt;%
-  ungroup() %&gt;%
-  filter(co2_kg&gt;0) %&gt;%
-  select(iso2, year, co2_kg) %&gt;%
-  pivot_wider(id_cols = c(iso2), names_from = year, values_from = co2_kg) %&gt;%
-  drop_na() %&gt;%
-  select(iso2) %&gt;%
-  pull()
-
-hh_data %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-ggplot(aes(x=year, y=hh*0.000001)) +
-  geom_line() +
-  geom_point(data=hh_data %&gt;% 
-               filter(iso2 %in% complete_countries,
-                      year&lt;=2015, 
-                      year&gt;=2005,
-                      imputed), color=&quot;red&quot;) +
-  theme_ipsum() +
-  scale_x_continuous(labels = scales::label_number(accuracy = 1, big.mark = &quot;&quot;)) +
-  labs(x=&quot;&quot;, y=&quot;Total number of households (mio)&quot;) +
-  facet_wrap(~iso3, scales=&quot;free_y&quot;, ncol = 4) +
-  theme(legend.position = &quot;bottom&quot;, 
-        axis.text.x = element_text(angle = 90))
-
-#ggsave(here(&quot;figures&quot;, &quot;household_size.png&quot;), plot = p, width = 8, height = 14)
-
-pal &lt;- wes_palette(&quot;Cavalcanti1&quot;, 5, type = &quot;discrete&quot;)
-pal = pal[c(1,2,5)]
-
-df_adult_e_p_hh %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  ggplot(aes(x=quint, y=adult_e_p_hh, color=factor(year))) +
-  geom_line(alpha=0.5) +
-  theme_ipsum() +
-  scale_color_manual(name = &quot;Year&quot;, values = pal) +
-  labs(x=&quot;&quot;, y=&quot;Adult equivivalents per household&quot;) +
-  facet_wrap(~iso3, ncol = 4) +
-  theme(legend.position = &quot;bottom&quot;, 
-        axis.text.x = element_text(angle = 90))
-
-#ggsave(here(&quot;figures&quot;, &quot;adult_eq_per_household.png&quot;), plot = p, width = 8, height = 14)
-
-df_adult_e_p_hh %&gt;%
-  filter(iso2 %in% complete_countries, year&lt;=2015, year&gt;=2005) %&gt;%
-  mutate(quint = parse_number(quintile)) %&gt;%
-  write_csv(here(&quot;data&quot;, &quot;adult_eq_per_household.csv&quot;))
-
-# 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 &lt;- function(pyear, pquantile_count=10) {
-  
-  country_data_annual_sorted = summary_country_fd %&gt;%
-    ungroup() %&gt;%
-    filter(year==pyear) %&gt;%
-    arrange(fd_pae_e) %&gt;%
-    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 %&gt;%
-    filter(year==1)
-  
-  # store quantile split values
-  eu_quantile_boundaries = data.frame(euro_q_rank = 1:pquantile_count, p = 0)
-  
-  ## can&#39;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[&quot;ae_quintile&quot;] + eu_ae_current &lt;= eu_decile_adult_eq) {
-      eu_ae_current = eu_ae_current + row[&quot;ae_quintile&quot;]
-      country_data_annual_sorted[row_idx, &quot;eu_q_rank&quot;] = 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, &quot;eu_q_rank&quot;] = euro_q_rank_current
-      new_row[1, &quot;ae_quintile&quot;] = ae_diff
-      ## record eu quantile boundary
-      eu_quantile_boundaries[eu_quantile_boundaries$euro_q_rank==euro_q_rank_current, &quot;p&quot;] =
-        country_data_annual_sorted[row_idx, &quot;fd_pae_e&quot;]
-      ## put first part of population in overflow dataframe
-      additional_rows = additional_rows %&gt;%
-        bind_rows(new_row)
-      ## classify rest of country quinitle population to next euro quantile
-      country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;] = 
-        country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;] - (ae_diff+0.0001)
-      euro_q_rank_current = euro_q_rank_current + 1
-      country_data_annual_sorted[row_idx, &quot;eu_q_rank&quot;] = euro_q_rank_current
-      eu_ae_current = country_data_annual_sorted[row_idx, &quot;ae_quintile&quot;]
-      
-    }
-  }
-  
-  country_data_eu_quantiles = country_data_annual_sorted %&gt;%
-  bind_rows(additional_rows) %&gt;%
-  arrange(fd_pae_e, eu_q_rank) %&gt;%
-  mutate(idx = 1:n())
-
-  #ad zeroth and nth quantile (min and max)
-  eu_quantile_boundaries[pquantile_count, &quot;p&quot;] = max(country_data_eu_quantiles$fd_pae_e)
-  #tmp = data.frame(euro_q_rank = 0, p = min(country_data_eu_quantiles$fd_pae_e)) %&gt;%
-  #  bind_rows(eu_quantile_boundaries) 
-  
-  
-  list(&quot;df_q_data&quot; = country_data_eu_quantiles, &quot;df_q_boundaries&quot; = eu_quantile_boundaries)
-}
-
-# maps MRIO results to EU ntile ranks, returns mapping and ntile EU boundaries
-map_mrio_results_to_eu_ntiles &lt;- 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 %&gt;%
-    group_by(coicop) %&gt;%#
-    summarise(coicop = first(coicop)) %&gt;%
-    ungroup()
-  
-  df_mapped_data = mrio_results_with_adult_eq %&gt;%
-    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) %&gt;%
-    filter(year==pyear) %&gt;%
-    # 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) %&gt;%
-    # 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)) %&gt;%
-    full_join(df_eu_ntiles_data %&gt;%
-                rename(fd_pae_e_quint_tmp = fd_pae_e), by=c(&quot;iso2&quot;, &quot;quint&quot;)) %&gt;%
-    rename(adult_eq = ae_quintile) %&gt;% # 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
-           ) #%&gt;%
-    #left_join(sector_mapping, by=&quot;sector_id&quot;)
-  
-  list(&quot;df_mapped_data&quot; = df_mapped_data, &quot;df_ntile_boundaries&quot; = 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 %&gt;%
-  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 %&gt;%
-  group_by(iso2, year, quint) %&gt;%
-  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 %&gt;%
-  group_by(iso2, year, quint) %&gt;%
-  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 %&gt;%
-  bind_rows(df_mapped_result_2010_data) %&gt;%
-  bind_rows(df_mapped_result_2015_data)
-
-write_csv(df_mapped_result_data, 
-          here(paste0(&quot;data/mrio_results_eu_ntile_mapped_n_&quot;, target_eu_ntiles, &quot;_method2_ixi.csv&quot;)))
-
-df_mapped_result_ntiles = 
-  df_mapped_result_2005_ntiles %&gt;% mutate(year=2005) %&gt;%
-  bind_rows(df_mapped_result_2010_ntiles %&gt;% mutate(year=2010)) %&gt;%
-  bind_rows(df_mapped_result_2015_ntiles %&gt;% mutate(year=2015))
-
-write_csv(df_mapped_result_ntiles, 
-          here(paste0(&quot;data/eu_ntiles_n_&quot;, target_eu_ntiles, &quot;_method2_ixi.csv&quot;)))</code></pre>
 </div>