View source: R/getSuitability.R
getSuitability | R Documentation |
This function measures how suitable an observation is given set of metrics that tend to increase the favorability of a location. Z-scores are first calculated for each metric (with an optional threshold). These are then standardized between [0,1], and a weighted mean between all metrics is performed to find the global suitability. Values of zero indicate that all of the least-favorable values are coincident at that observation; values of one indicate that the location sees all of the most favorable conditions for each metric.
getSuitability(
x,
group.var = NULL,
weights = NULL,
suit.name = "Suit",
stdev = 2,
keep.vars = FALSE
)
x |
a numeric vector, data.frame, or data.table with metrics representing
values that tend to increase (or decrease, if negative |
group.var |
(Optional) A character string representing the name of the column with group IDs, such that z-scores and suitabilities are calculated only within groups. |
weights |
(Optional) A named list of numerics or vector of class numeric
by which to weigh favorability observations in the final suitability estimate.
If |
suit.name |
The name of the output net suitability column. Default is
|
stdev |
The threshold value for z-scores (see |
keep.vars |
Should the thresheld z-scores for each variable be kept? Default
is |
# Creata dummy data
x <- data.table(A = c(1:10),
B = c(11:20),
C = c(21:30),
D = c(31:40),
ID = rep(c("a","b"),5))
# Create weights, don't consider 'C'
weights <- list(A = 1,
B = 2,
D = -1)
# Get suitabilities
getSuitability(x, group.var = 'ID', weights = weights, keep.vars = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.