For a contingency table in array form, compute the sum of table entries for a given index.
index number (1 for rows, etc.)
This is really just
apply(x, margin, sum) packaged up for
newbies, except that if
margin has length zero you get
The relevant marginal table. The class of
x is copied to the
output table, except in the summation case.
1 2 3