abs()
get_help() docs
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.
abs(number to get the absolute value of)
abs(numeric array to get the absolute value of all its values)# 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