forked from OHI-Science/ohi-global
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_goal_inputs.rmd
66 lines (53 loc) · 2.28 KB
/
table_goal_inputs.rmd
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
64
---
title: "compare goals.csv inputs across scenarios"
author: "Julie Lowndes"
date: "August 1, 2014"
output:
md_document:
variant: markdown_github
html_document:
fig_caption: yes
number_sections: yes
toc: yes
---
This table compares the years assigned in the 'preindex_function' field of `goals.csv`: these years will be used in `functions.r` to calculate goal scores. Note: this table has been simplified to only show years. Rerun `preindex_functions.rmd` for the most current version; you can also see the code that makes this table.
Currently for scenarios **eez2012, eez2013, eez2014**.
``` {r, eval=TRUE, message = FALSE, echo=FALSE}
library(dplyr)
library(stringr)
library(pander)
# identify scenarios
scenarios = c('eez2012',
'eez2013',
'eez2014')
# loop through scenarios
if (exists('d')) rm(d)
for (i in 1:length(scenarios)) { # i=1
f = read.csv(sprintf('%s/conf/goals.csv', scenarios[i])) %>%
select(goal, preindex_function)
# g = str_split(f$preindex_function, ',')
g = f %>%
mutate(yrs_set = preindex_function,
yrs_set = str_replace_all(yrs_set, 'LIV_ECO\\(layers, subgoal\\=\'LIV\', ', 'LIV\\('),
yrs_set = str_replace_all(yrs_set, 'LIV_ECO\\(layers, subgoal\\=\'ECO\', ', 'ECO\\('),
yrs_set = str_replace_all(yrs_set, 'liv_workforcesize_year', 'wfsize_yr'),
yrs_set = str_replace_all(yrs_set, 'eco_rev_adj_min_year', 'revadj_minyr'),
yrs_set = str_replace_all(yrs_set, 'layers,* *', ''),
yrs_set = str_replace_all(yrs_set, 'scores,* *', ''),
yrs_set = str_replace_all(yrs_set, 'year', 'yr'),
yrs_set = str_replace_all(yrs_set, 'status', 'st'),
yrs_set = str_replace_all(yrs_set, 'trend', 'tr'),
yrs_set = str_replace_all(yrs_set, 'yrs', 'yr')) %>%
select(goal, yrs_set)
names(g) = c('goal', sprintf('yrs_set_%s', scenarios[i]))
# rbind
if (!exists('d')){
d = g
} else {
d = d %>%
inner_join(g, by='goal')
}
}
pander(d, justify = 'left', split.tables = 100,
caption = sprintf('Comparison of scenarios %s, %s, and %s', scenarios[1], scenarios[2], scenarios[3]))
```