Skip to content
Related Articles
Open in App
Not now

Related Articles

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

Improve Article
Save Article
  • Last Updated : 24 Jun, 2020
Improve Article
Save Article

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
Related Articles

Start Your Coding Journey Now!