sweep {base} | R Documentation |
Sweep out Array Summaries
Description
Return an array obtained from an input array by sweeping out a summary statistic.
Usage
sweep(x, MARGIN, STATS, FUN="-", ...)
Arguments
x |
an array. |
MARGIN |
a giving the extents of |
STATS |
the summary statistic which is to be swept out. |
FUN |
the function to be used to carry out the sweep. In the
case of binary operators such as |
... |
optional arguments to |
Value
An array with the same shape as x
, but with the summary
statistics swept out.
See Also
apply
on which sweep
is based;
scale
for centering and scaling.
Examples
data(attitude)
med.att <- apply(attitude, 2, median)
sweep(data.matrix(attitude), 2, med.att)# subtract the column medians