Get binary sign of a variable, or array

sign_no_zero(x)

Arguments

x

a vector or array

Value

a vector or array telling if each element of x is greater than or equal to zero. This array will be of the same dimension as x, but with elements -1 for negative values of x, and elements +1 for positive values of x

See also

Examples

sign_no_zero(-2:2) #returns -1 -1 1 1 1
#> [1] -1 -1 1 1 1