This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/sweep.html
sweep {base}R Documentation

Sweep out Array Summaries

Usage

sweep(x, MARGIN, STATS, FUN="-", ...)

Arguments

x

an array.

MARGIN

a giving the extents of x which correspond to STATS.

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 "/" etc., the function name must be quoted.

...

optional arguments to FUN.

Value

An array with the same shape as x, but with the summary statistics swept out.

See Also

apply.

Examples

data(attitude)
med.att <- apply(attitude, 2, median)
sweep(data.matrix(attitude), 2, med.att)# subtract the column medians

[Package base version 0.60 ]