Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Calculate the Median Absolute Deviation in R Programming – mad() Function

  • Last Updated : 24 Jun, 2020

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 vector
x <- c(1:9)
  
# Calling mad() Function
mad(x)

Output:

[1] 2.9652

Example 2:




# R Program to calculate 
# Median Absolute Deviation
  
# Creating a vector
x <- c(1, 4, 2, 3, 7, 3, 8, 9, 2)
  
# Calling mad() Function
mad(x)

Output:

[1] 1.4826
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!