n_dist2targ {COINr}R Documentation

Normalise as distance to target


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.


n_dist2targ(x, targ, direction = 1, cap_max = FALSE)



A numeric vector


An target value


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.


If TRUE, any value of x that exceeds targ will be assigned a score of 1, otherwise will have a score greater than 1.


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.


Numeric vector


x <- runif(20)
n_dist2targ(x, 0.8, cap_max = TRUE)

[Package COINr version 1.1.14 Index]