separate_values | R Documentation |
Separates real numbers from one another that are to close to each other. In the resulting set, the values are separated by a minimum distance, bounded by lower and upper limits and are constraint to be as close as possible to their original values.
separate_values(X, distance = 0.05, min = 0, max = 1)
X |
numerical vector of real numbers. |
distance |
minimum distance between subsequent numbers. Must be a scalar or vector of size |
min, max |
lower and upper limits. |
This function can be used for example to separate labels that are too close to one another. The resulting vector will create enough space, such that the labels do not overlap any more, yet are still close to their original values.
The output vector has the following properties. For all elements e_i
, min <= e_i <= max
.
For the distance D
between e_i
and e_(i+1)
, D >= max(d_i, d_(i+1))
. And finally, the distance
between e_i
and X_i
is minimized for all e_i
.
A numerical vector with the same length as X
, with numbers bounded by min and max, close to their original values and
with the minimum allowed distance between subsequent values.
separate_values(c(0.3,0.4,0.41), distance = 0.05, min = 0, max = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.