For a contingency table in array form, compute the sum of table entries for a given index.
Equivalent to apply(x, margin, sum)
except that it returns sum(x)
if margin has length zero
m <- matrix(1:4, 2)
margin.table(m, 1)
margin.table(m, 2)
viewed on http://www.rfunction.com