abs()
   get_help() docs


Description

The abs() function comes with R and is part of the Base R {base} package.

We use this function to calculate the absolute value a number or numeric array.

Conceptual Usage

abs(number to get the absolute value of)

abs(numeric array to get the absolute value of all its values)

Examples

# Find the absolute value of 107
abs(107)
## [1] 107


# Find the absolute value of -107
abs(-107)
## [1] 107


# Find the absolute value of a defined variable
x <- -107
abs(x)
## [1] 107


# Find the absolute value of all values in an array
abs( c(100, -110, 120, -50, -30) )
## [1] 100 110 120  50  30