\Header{sweep}{Sweep out Array Summaries}
\keyword{array}{sweep}
\keyword{iteration}{sweep}
\begin{Usage}
\begin{verbatim}
sweep(x, MARGIN, STATS, FUN="-", ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] an array.
\item[\texttt{MARGIN}] a giving the extents of \texttt{x} which correspond to \texttt{STATS}.
\item[\texttt{STATS}] the summary statistic which is to be swept out.
\item[\texttt{FUN}] the function to be used to carry out the sweep.
In the case of binary operators such as \texttt{"/"} etc.,
the function name must be quoted.
\item[\texttt{...}] optional arguments to \texttt{FUN}.
\end{ldescription}
\end{Arguments}
\begin{Value}
An array with the same shape as \texttt{x}, but with the summary
statistics swept out.\end{Value}
\begin{SeeAlso}
\texttt{\Link{apply}} on which \texttt{sweep} is based;
\texttt{\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}

