Get the module of a negative number in R

2

Is there a function in R to get the module of a negative number or a vector of numbers?

example:

v <- c(1,-2,3,-4)

module(v)

#> [1]  1 2 3 4
    
asked by anonymous 03.06.2016 / 14:54

1 answer

4

Use the function abs (value abs oluto):

> v <- c(1,-2,3,-4)
> abs(v)
[1] 1 2 3 4
    
03.06.2016 / 16:34