Calculate all scores, given layers and configuration.

CalculateAll(conf, layers)

Arguments

conf

of class Conf

layers

of class Layers

debug

print debug messages (default = FALSE)

Value

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)

Details

Performs the following sequence of functions, some of which are optional:

  1. 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.

  2. CalculatePressuresAll() - calculate pressures across all goals using pressures_matrix.csv.

  3. CalculateResilienceAll() - calculate resilience across all goals using resilience_matrix.csv and resilience_weights.csv.

  4. 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.

  5. CalculateGoalIndex() - run function for every goal having a status dimension assigned from the preindex_functions.

  6. 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.

  7. regional index - calculate regional index score as weighted mean using goals.csv: weight.

  8. regional likely future - calculate regional likely future score (ie goal='Index' and dimension='future') across supragoals (ie goals without a parent in goals.csv).

  9. [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.

  10. global (region_id=0) scores - calculate scores for global (region_id=0) with regional values weighted by config.R: layer_region_areas.

  11. [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.

Examples

# 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) # }