metric.score: Score metrics

Description Usage Arguments Value Examples

View source: R/metric.score.R

Description

This function calculates metric scores based on a Thresholds data frame. Can generate scores for 1/3/5 (ScoreRegime="135") or 0-100 (ScoreRegime="100").

Usage

1
metric.score(MetricName, MetricValue, IndexName, IndexRegion, Thresh)

Arguments

MetricName

metric abbreviation

MetricValue

calculated metric value

IndexName

name of index (e.g., MBSS.2005.Bugs)

IndexRegion

relevant bioregion or site class for given index

Thresh

Data frame of Scoring Thresholds (Index.Name, Index.Region, Metric, Direction, Thresh.Lo, Thresh.Hi, ScoreRegime)

Value

vector of scores

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Load thresholds
thresh <- metrics_scoring
View(thresh)
## Define Index
IndexName <- "MBSS.2005.Bugs"

## Score Single Value
MetricName <- "nt_total"
MetricValue <- 18
IndexRegion <- "CP"
metric.score(MetricName,MetricValue,IndexName,IndexRegion,thresh)

## Score Data Frame of Values
# get metrics to score
myMetrics <- as.character(droplevels(unique(thresh[thresh[,"Index"]==IndexName,"Metric"])))
for (i in myMetrics){##FOR.i.START
  i.sc.nam <- paste0("Sc_",i)
  i.val <- Metrics.Bugs[,i]
  Metrics.Bugs[,i.sc.nam] <- metric.score(i,i.val,Metrics.Bugs$Index,Metrics.Bugs$Region,thresh)
  #
}##FOR.i.END
#
## View Results
View(Metrics.Bugs)

leppott/MMIcalc documentation built on May 21, 2019, 5:10 a.m.