abs
Absolute Value

Description

Returns the absolute value of each element of the input.

Usage

abs(x)

Arguments

x an object with mode "logical", "numeric" or "complex". Missing values (NAs) are allowed.

Details

This function is a member of the Math group of generic functions.
Value
returns an object like x, with the absolute value of each data value taken. If x is a complex number, its modulus is returned. That is, Mod(x).
Classes
This function is used as the default method for classes that do not inherit a specific method for the function or for the Math group of functions. The result retains the class and the attributes. If this behavior is not appropriate, the designer of the class should provide a method for the function or for the Math group,
See Also
Complex
Examples
abs(rnorm(10)) # vector of length 10 
abs(matrix(rnorm(10), 2)) # 2 by 5 matrix 

abs(c(-2+4i, 5-3.2i)) # complex number. # [1] 4.472136 5.936329

x <- rnorm(10) > 0 # logical vector abs(x) # result is numeric vector

Package base version 6.1.1-7
Package Index