powered by
A measure of the distance to a specific value found in x, specified by iref. The formula is:
x
iref
n_dist2ref(x, iref, cap_max = FALSE)
Numeric vector
A numeric vector
An integer which indexes x to specify the reference value. The reference value will be x[iref].
x[iref]
If TRUE, any value of x that exceeds x[iref] will be assigned a score of 1, otherwise will have a score greater than 1.
TRUE
$$ 1 - (x_{ref} - x)/(x_{ref} - x_{min}) $$
Values exceeding x_ref can be optionally capped at 1 if cap_max = TRUE.
x_ref
cap_max = TRUE
x <- runif(20) n_dist2ref(x, 5)
Run the code above in your browser using DataLab