\Header{sweep}{Sweep out Array Summaries}
\keyword{array}{sweep}
\keyword{iteration}{sweep}
\begin{Description}\relax
Return an array obtained from an input array by sweeping out a summary
statistic.\end{Description}
\begin{Usage}
\begin{verbatim}
sweep(x, MARGIN, STATS, FUN="-", ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an array.
\item[\code{MARGIN}] a vector of indices giving the extents of \code{x}
which correspond to \code{STATS}.
\item[\code{STATS}] the summary statistic which is to be swept out.
\item[\code{FUN}] the function to be used to carry out the sweep.  In the
case of binary operators such as \code{"/"} etc., the function name
must be quoted.
\item[\code{...}] optional arguments to \code{FUN}.
\end{ldescription}
\end{Arguments}
\begin{Value}
An array with the same shape as \code{x}, but with the summary
statistics swept out.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{apply}} on which \code{sweep} is based;
\code{\Link{scale}} for centering and scaling.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(attitude)
med.att <- apply(attitude, 2, median)
sweep(data.matrix(attitude), 2, med.att)# subtract the column medians
\end{ExampleCode}
\end{Examples}

