Create Contingency Table from Categories

DESCRIPTION:
Returns a contingency table (array) with the same number of dimensions as arguments given.

USAGE:
table(..., exclude=c(NA,NaN))

REQUIRED ARGUMENTS:
...:
any number of objects, each to be interpreted as a category. All arguments must be of equal length. Together, they define a multi-way ragged array of as many dimensions as there are arguments. Missing values (NAs) are allowed. Arguments that are given in the name=value form will have a name in the dimnames list.

OPTIONAL ARGUMENTS:
exclude:
vector of objects to use as the exclude argument to category when creating categories out of objects that are not already categories.

VALUE:
a multi-way array containing the number of observations in the cells defined by the arguments to table. For example, if z <- table(arg1, arg2, arg3) then z[i,j,k] is the number of times that the combination of the i-th level of the first category, the j-th level of the second, and the k-th level of the third appeared together in the data. A combination is not counted if missing values are present in the corresponding element of any of the arguments.

The dimnames attribute of the array contains the levels attribute of each of the arguments.


DETAILS:
Returns a multi-way array containing the number of observations in the cells defined by the arguments to table.

SEE ALSO:
crosstabs , cut , na.include , factor , loglin , tapply , tabulate , category .

EXAMPLES:
Pet <- factor(c("Cat","Dog","Cat","Dog","Cat","?"), exclude="?")
Food <- factor(c("Dry","Dry","Dry","Wet","Wet","Wet"))
table(Pet, Food)

# produces the following output: Dry Wet Cat 2 1 Dog 1 1

table(na.include(Pet), Food)

Dry Wet Cat 2 1 Dog 1 1 NA 0 1