The functions compute the sum or mean of all pairwise absolute
differences. This differs from
stats::mad(), which computes
the median absolute difference of each value from the median of
all the values. See the
ISIwithR package (and the textbook it
accompanies) for examples using these functions in the context of
a numeric vector or a formula.
additional arguments passed through to
x is a formula,
include an argument named
data if the intent is to
interpret the formula in a data frame.
a data frame in which to evaluate formulas (or bare names).
Note that the default is
data = parent.frame(). This makes it convenient to
use this function interactively by treating the working environment as if it were
a data frame. But this may not be appropriate for programming uses.
When programming, it is best to use an explicit
-- ideally supplying a data frame that contains the variables mentioned.
a grouping variable, typically a name of a variable in
a logical indicating whether NAs should be removed before calculating.
the mean or sum of the absolute differences between each pair
of values in
SAD(1:3) #>  4 MAD(1:3) #>  1.333333 MAD(~eruptions, data = faithful) #>  171.5886