Tuesday 7 February 2017

sign function in R

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).

sign {base}

> sign(20)
[1] 1
> sign(-10)
[1] -1
> sign(0)

[1] 0

Note that sign does not operate on complex vectors.

No comments:

Post a Comment