Get the module of a negative number in R

Asked

Viewed 3,996 times

4

Is there any function in R to obtain the module of a negative number or a number vector?

example:

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

module(v)

#> [1]  1 2 3 4

1 answer

7


Use the function abs (value absoluto):

> v <- c(1,-2,3,-4)
> abs(v)
[1] 1 2 3 4

Browser other questions tagged

You are not signed in. Login or sign up in order to post.