Classify the sign of the elements of a vector
signum(x, epsilon = 1e-05)
x | vector of values to test |
---|---|
epsilon | magnitude threshold |
Returns a vector with elements +1,0 or -1.
Calculates the sign of the elements of then vector x, except that values less than epsilon in magnitude are rounded down to zero.
signum(c(-40,-3,-0.1E-8,0,2,5))#> [1] -1 -1 0 0 1 1