n_dist2targ {COINr} | R Documentation |
Normalise as distance to target
Description
A measure of the distance of each value of x
to a specified target which can be a high or low target depending on direction
. See details below.
Usage
n_dist2targ(x, targ, direction = 1, cap_max = FALSE)
Arguments
x |
A numeric vector |
targ |
An target value |
direction |
Either 1 (default) or -1. In the former case, the indicator is assumed to be "positive" so that the target is at the higher end of the range. In the latter, the indicator is "negative" so that the target is typically at the low end of the range. |
cap_max |
If |
Details
If direction = 1
, the formula is:
\frac{x - x_{min}}{x_{targ} - x_{min}}
else if direction = -1
:
\frac{x_{max} - x}{x_{max} - x_{targ}}
Values surpassing x_targ
in either case can be optionally capped at 1 if cap_max = TRUE
.
This function also supports parameter specification in iMeta
for the Normalise.coin()
method.
To do this, add columns Target
, and dist2targ_cap_max
to the iMeta
table, which correspond
to the targ
and cap_max
parameters respectively. Then set f_n_para = "use_iMeta"
within the
global_specs
list. See also examples in the normalisation vignette.
Value
Numeric vector
Examples
x <- runif(20)
n_dist2targ(x, 0.8, cap_max = TRUE)