# sign Function in R (Example)

In this R tutorial youâ€™ll learn how to **find out if a numeric value is positive or negative**.

The post looks as follows:

Hereâ€™s how to do it.

## Definition & Basic R Syntax of sign Function
##

**Definition:** The sign R function returns the signs of numeric elements. The value 1 is returned for positive numbers, the value 0 is returned for zero, and the value -1 is returned for negative numbers.

**Basic R Syntax:** You can find the basic R programming syntax of the sign function below.

sign(5) # Basic R syntax of sign function

In the remaining tutorial, Iâ€™ll illustrate in an example how to apply the sign function in the R programming language.

## Example: Return whether Number is Positive or Negative

The R programming syntax below illustrates how to use the sign() command in the R programming language. Within the sign function, we simply need to specify a vector of numeric values:

sign(-2:5) # Apply sign function # -1 -1 0 1 1 1 1 1

The first two elements of our vector are negative (indicated by -1), the third element is zero (indicated by 0), and the remaining elements are positive (indicated by +1).

## Video & Further Resources

Would you like to know more about the sign function? Then you could watch the following video which I have published on my YouTube channel. In the video, I show the content of this post.

Furthermore, you may read the other tutorials which I have published on this homepage.

- How to Calculate an Absolute Value
- Square Root in R
- R Functions List (+ Examples)
- The R Programming Language

In summary: In this article you learned how to **apply the sign function** in R. In case you have additional questions, please tell me about it in the comments section.