This function computes the *average absolute deviation*, i.e. the mean of the absolute deviations from a central point (median by default).
Arguments
- x
(named) numerical vector
- i
(optional) numerical vector giving the position in
x
or character vector matching the names inx
. Ifmissing
ori = NULL
, the entirex
is considered for the computation of the score- na.rm
logical, whether to remove
NA
values fromx
before computation- center
numerical value, the central point
Value
A numerical value representing the computed measure.
A default NA
value is returned if the score can't be
computed.
Examples
x = c(2,2,3,4,14)
AAD(x = x, center = median(x))#2.8
#> [1] 2.8
AAD(x = x, center = mean(x))#3.6
#> [1] 3.6
AAD(x = x, center = modalValue(x))#3.0
#> [1] 3