Calculate all scores, given layers and configuration.
CalculateAll(conf, layers)
conf | of class |
---|---|
layers | of class |
debug | print debug messages (default = FALSE) |
Returns a data.frame of scores having the following columns:
region_id - unique numeric region identifier, reserving 0 for the area-weighted average of the entire study area
goal - the goal code or Index
dimension - the dimension code, one of: status, trend, pressures, resilience, future, score
score - the numeric score: 0-100 for all dimensions, except trend (-1 to 1)
Performs the following sequence of functions, some of which are optional:
Setup()
- execute function Setup()
if defined in file functions.R
.
This function typically installs extra packages upon which the other functions in functions.R depend.
CalculatePressuresAll()
- calculate pressures across all goals using pressures_matrix.csv.
CalculateResilienceAll()
- calculate resilience across all goals using resilience_matrix.csv and resilience_weights.csv.
goals.csv:preindex_functions
- execute code in the preindex_function
column of the goals.csv file
based on order_calculate
using functions defined in functions.R.
These funcutions are usually for calculating the goal's status and trend dimensions, i.e.
the additional dimensions beyond pressures and resilience needed to calculate a goal index score.
CalculateGoalIndex()
- run function for every goal having a status dimension assigned from the preindex_functions
.
goals.csv:postindex_functions
- execute code in the postindex_function
column of the goals.csv file based on order_calculate
using functions defined in functions.R. These functions are usually for goals containing subgoals, ie those without their own directly calculated
index scores, but rather scores representing averages of subgoals.
regional index - calculate regional index score as weighted mean using goals.csv: weight
.
regional likely future - calculate regional likely future score (ie goal='Index' and dimension='future') across supragoals (ie goals without a parent
in goals.csv).
[functions.R:PreGlobalScores
()] - execute function PreGlobalScores
() if defined in file functions.R
.
This function could perform a variety of operations on the regional scores, strategically before calculating the global scores.
global (region_id=0) scores - calculate scores for global (region_id=0) with regional values weighted by config.R: layer_region_areas
.
[functions.R:FinalizeScores
()] - execute function FinalizeScores
() if defined in file functions.R.
This function could perform a variety of operations on the regional and global scores.
# NOT RUN { ## run a scenario assuming setwd() to directory containing default names for directories and files ## setup require(ohi) conf = Conf('conf') layers = Layers(layers.csv = 'layers.csv', layers.dir = 'layers') ## calculate scores = CalculateAll(conf, layers, debug=T) ## write write.csv(scores, 'scores.csv', na='', row.names=F) # }