separate_values {hgutils}R Documentation

Separate values

Description

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.

Usage

separate_values(X, distance = 0.05, min = 0, max = 1)

Arguments

X

numerical vector of real numbers.

distance

minimum distance between subsequent numbers. Must be a scalar or vector of size |X|.

min, max

lower and upper limits.

Details

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.

Value

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.

Examples

separate_values(c(0.3,0.4,0.41), distance = 0.05, min = 0, max = 1)

[Package hgutils version 0.2.11 Index]