# Calculate the absolute value in R programming – abs() method

method in R programming is used to get the absolute value that is positive value doesn’t change and negative value converted into positive value.**abs()**

Syntax:`abs(value)`

Return:Returns the absolute value.

**Example 1:**

`# R program to calculate absolute value` ` ` `# Using abs() method` `answer1 <` `-` `abs` `(` `-` `12` `)` `answer2 <` `-` `abs` `(` `21` `)` `answer3 <` `-` `abs` `(` `-` `2` `)` ` ` `print` `(answer1)` `print` `(answer2)` `print` `(answer3)` |

**Output:**

[1] 12 [2] 21 [3] 2

**Example 2:**

`# R program to calculate absolute value` ` ` `# Using abs() method` `answer1 <` `-` `abs` `(c(` `1` `, ` `2` `, ` `3` `, ` `4` `))` `answer2 <` `-` `abs` `(c(` `1` `, ` `-` `2` `, ` `3` `, ` `-` `4` `))` ` ` `print` `(answer1)` `print` `(answer2)` |

**Output:**

[1] 1 2 3 4 [2] 1 2 3 4