Skip to content
Related Articles

Related Articles

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to calculate 
# Median Absolute Deviation
  
# Creating a vector
x <- c(1:9)
  
# Calling mad() Function
mad(x)

chevron_right


Output:

[1] 2.9652

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

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