Calculate the Median Absolute Deviation in R Programming – mad() Function
mad() function in R Language is used to compute the median absolute deviation i.e. the (lo-/hi-)median of the absolute deviations from the median.
Syntax: mad(x)
Parameters:
x: Vector
Example 1:
# R Program to calculate # Median Absolute Deviation # Creating a vectorx <- c(1:9) # Calling mad() Functionmad(x) |
Output:
[1] 2.9652
Example 2:
# R Program to calculate # Median Absolute Deviation # Creating a vectorx <- c(1, 4, 2, 3, 7, 3, 8, 9, 2) # Calling mad() Functionmad(x) |
Output:
[1] 1.4826



