\Header{margin.table}{Compute table margin}
\keyword{array}{margin.table}
\begin{Description}\relax
For a contingency table in array form, compute the sum of table
entries for a given index.
\end{Description}
\begin{Usage}
\begin{verbatim}
margin.table(x, margin=NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an array
\item[\code{margin}] index number (1 for rows, etc.) 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This is really just \code{apply(x, margin, sum)} packaged up for
newbies, except that if \code{margin} has length zero you get
\code{sum(x)}.
\end{Details}
\begin{Value}
The relevant marginal table.  The class of \code{x} is copied to the
output table, except in the summation case.
\end{Value}
\begin{Author}\relax
Peter Dalgaard
\end{Author}
\begin{Examples}
\begin{ExampleCode}
m <- matrix(1:4,2)
margin.table(m,1)
margin.table(m,2)
\end{ExampleCode}
\end{Examples}

