-
Notifications
You must be signed in to change notification settings - Fork 0
/
7b_prepare_oecd_AEA.R
51 lines (40 loc) · 1.64 KB
/
7b_prepare_oecd_AEA.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#'
#'
#'
#' @author Simon Schulte
#' Date: 2023-07-11 15:04:37.369072
#'
#' Content:
#'
############################################################################## #
##### load packages ############################################################
############################################################################## #
library(data.table)
library(tidyverse)
library(units)
library(ggforce)
library(logr)
library(mRio)
library(countrycode)
############################################################################## #
##### settings #################################################################
############################################################################## #
source(file.path('src', 'functions.R'))
# read config and setup log script
config <- setup_config_and_log()
path2output <- config$path2output
theme_set(theme_bw())
############################################################################## #
##### functions #################################################################
############################################################################## #
############################################################################## #
##### load data #############################################################
############################################################################## #
dt <- fread(config$path2oecd)
dt <- dt[ACTIVITY %in% c('IND-TOTAL', 'HH-TOTAL')]
dt[, emissions_OECD := Value / 1E3]
dt[, country := countrycode(COUNTRY, 'iso3c', 'iso2c')]
dt <- dt[, .(country, POLLUTANT, ACTIVITY, emissions_OECD)]
setnames(dt, c('POLLUTANT', 'ACTIVITY'), c('gas', 'activity'))
dt
save_results(dt)