Newer
Older
Xinxin Yang
committed
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
############################################################################
############################################################################
### ###
### SECTION 3: ###
### Farm | Supply details ###
### ###
############################################################################
############################################################################
#################################################################
## Setup ##
#################################################################
# set currently working directory
gdx.dir <- paste0(getwd(), "/inst/extdata/gdx")
# define gdx file name for reading
file1 <- "res_2_1230cap_after_2014_refdefaultA" # refdefautA
file2 <- "res_2_1230fta_import_bandefaultA" # bandefaultA
# loaded gdx files and saved in dataout
outdata.dir <- paste0(getwd(), "/inst/outdata")
# Step 1: extract supply details with longname
# activitySel: Crops, Cereals, Activities, anyThing, Oilseeds, Crop aggregates, Aggregates
bs <- extract_supply_details_longname (region_list= "EU27yr19",
dimdef_activity = dimdef_activity,
activitySel= "Cereals",
scenario_list= file1,
folder = gdx.dir)
sc <- extract_supply_details_longname (region_list= "EU27yr19",
dimdef_activity = dimdef_activity,
activitySel= "Cereals",
scenario_list= file2,
folder = gdx.dir)
# step 2
# calculate abs and percent change then output tables
supply_tb <- cal_diff_percentage_change(bs,sc,supply_details = TRUE)
# step 3
# filter vectors and make a nice table
nicetable_supply_details(supply_tb, "Cereals", abs = 0, percent_change = 0, vector_list = "all")
nicetable_supply_details(supply_tb_2, "Cereals", abs = 104, percent_change = 2,
vector_list = c("diff_supply", "supply", "diff_yield", "yield",
"level", "diff_level"))
# gtsave(
# "supply_details_tb_activity_list.html", inline_css = FALSE,
# path = outdata.dir)