R abs — absolute value

In R, abs returns the magnitude of a number. For example, the absolute value of −6 is 6, and the absolute value of 0 is 0.

A simple example

abs

  1. Start with −3
  2. Do this Measure distance from zero
  3. Result 3
From −3, three unit steps reach zero. The magnitude is 3.
Lesson.R
cat(abs(-3), "\n", sep = "")
Output
3