.BG
.FN sweep
.TL
Sweep Out Array Summaries
.CS
sweep(A, MARGIN, STATS, FUN="\-", ...)
.AG A
array.  Missing values (`NA's) are allowed.
.AG MARGIN
vector describing the dimensions of `A' that correspond to
`STATS'.
.AG STATS
vector giving a summary statistic of array `A' that is to be
swept out.  Missing values (`NA's) are allowed.
.AG FUN
character string name of function to be used in sweep
operation.
.AG ...
additional arguments to `FUN', if any.
.RT
an array like `A', but with marginal statistics swept out as
defined by the other arguments. In the most common cases,
the function is "\-" or "/" to subtract or divide by statistics
that result from using the `apply' function on the array.
For example: `colmean <- apply(z,2,mean)' computes
column means of array `z'.  `zcenter <- sweep(z,2,colmean)'
removes the column means.
.PP
More generally, based on `MARGIN', there are one or more values of `A'
that would be used by `apply' to create `STATS'.  `sweep' creates an
array like `A' where the corresponding value of `STATS' is used in
place of each value of `A' that would have been used to create
`STATS'.  The function `FUN' is then used to operate
element-by-element on each value in `A' and in the constructed array.
.SA
`apply', `scale'.
.EX
a <- sweep(a,2,apply(a,2,mean)) # subtract col means
a <- sweep(a,1,apply(a,1,mean)) # subtract row means
     # a simple two-way analysis
.KW iteration
.KW array
.WR
