sign returns a vector with the signs of the corresponding elements of x (the sign of a real number is 1, 0, or \(-1\) if the number is positive, zero, or negative, respectively). Note that sign does not operate on complex vectors.
sign(x)
| Parameter | Description |
|---|---|
x |
a numeric vector |
# NOT RUN {
sign(pi) # == 1
sign(-2:3) # -1 -1 0 1 1 1
# }