table.matrix | R Documentation |
A version of the base table
function designed for matrices.
Taking a matrix as input, table.matrix
returns a contingency table,
index vector, and unique matrix.
table.matrix(data, MARGIN = 1)
data |
A matrix or data.frame, potentially containing non-unique patterns in its rows or columns. |
MARGIN |
A single integer specifying the array margin to be held fixed.
(To get unique rows, select |
To apply this function to the columns of a matrix, simply
transpose the matrix before executing the command, as in:
table.matrix(t(data))
.
A list with the following elements:
table
A contingency table of the counts of the number of occurrences of each unique row in the matrix.
index
An index vector containing the indices (row numbers), in a matrix composed only of unique rows, to which each row in the original matrix maps.
unique.data
A new matrix containing only the unique rows of the input matrix.
Caitlin Collins caitiecollins@gmail.com
## Not run:
## load example data:
data("snps.ace")
x <- snps.ace
## basic use of fn on rows of x:
tab.out <- table.matrix(x)
## apply fn to columns of x:
tab.out <- table.matrix(t(x))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.