Description Usage Arguments Details Value Note Examples
Computes the margin of a contingency table given as an array, by summing out over the dimensions not specified.
1 2  marginTable(x, margin = NULL, order = TRUE)
marginMatrix(x, margin, dim = NULL, incols = FALSE, order = FALSE)

x 
a numeric array 
margin 
integer vector giving margin to be calculated (1 for rows, etc.) 
order 
logical  should indices of output be ordered as in the vector

dim 
Integer vector containing dimensions of variables. Assumed all binary if not specified. 
incols 
Logical specifying whether not the distributions are stored as the columns in the matrix; assumed to be rows by default. 
With order = TRUE
this is the same as the base function
margin.table()
, but faster.
With order = FALSE
the function is even faster, but the indices in
the margin are returned in their original order, regardless of the way they
are specified in margin
.
propTable()
returns a renormalized contingency table whose entries
sum to 1. It is equivalent to prop.table()
, but faster.
The relevant marginal table. The class of x
is copied to the
output table, except in the summation case.
Original functions are margin.table
and
prop.table
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  m < matrix(1:4, 2)
marginTable(m, 1)
marginTable(m, 2)
propTable(m, 2)
# 3way example
m < array(1:8, rep(2,3))
marginTable(m, c(2,3))
marginTable(m, c(3,2))
marginTable(m, c(3,2), order=FALSE)
#' set.seed(2314)
# set of 10 2x2x2 probability distributions
x = rdirichlet(10, rep(1,8))
marginMatrix(x, c(1,3))
marginMatrix(t(x), c(1,3), incols=TRUE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.