rowTabulates {matrixStats}R Documentation

Tabulates the values in a matrix by row (column)

Description

Tabulates the values in a matrix by row (column).

Usage

   rowTabulates(x, values=NULL, ...)
   colTabulates(x, values=NULL, ...)
 

Arguments

x An integer or raw NxK matrix.
values An vector of values of count. If NULL, all (unique) values are counted.
... Not used.

Value

Returns a NxJ (KxJ) matrix where J is the number of values counted.

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

Examples

x <- matrix(1:5, nrow=10, ncol=5)
print(x)
print(rowTabulates(x))
print(colTabulates(x))
# Count only certain values
print(rowTabulates(x, values=1:3))

y <- as.raw(x)
dim(y) <- dim(x)
print(y)
print(rowTabulates(y))
print(colTabulates(y))

[Package matrixStats version 0.1.8 Index]