How to calculate abs() of a value in R
The abs() function returns the absolute value of a number.
Figure 1 shows a mathematical representation of the abs() function.
Syntax
abs(num)
## where num is the number whose absolute value is required
Parameter
The abs() function takes a number as a parameter.
Return value
The abs() function returns the absolute value of the number passed as a parameter.
Code
#Positive numbera <- abs(5);print(paste0("abs(5): ", a))#negative numberb <- abs(-5);print(paste0("abs(-5): ", b))#zeroc <- abs(0);print(paste0("abs(0): ", c))