rowTabulates: Tabulates the values in a matrix by row (column)

Description Usage Arguments Value Author(s) Examples

Description

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

Usage

1
2
3
4
  ## S3 method for class 'matrix'
rowTabulates(x, values=NULL, ...)
  ## S3 method for class 'matrix'
colTabulates(x, values=NULL, ...)

Arguments

x

An integer or raw NxK matrix.

values

An vector of J values of count. If NULL, all (unique) values are counted.

...

Not used.

Value

Returns a NxJ (KxJ) matrix where N (K) is the number of row (column) vectors tabulated and J is the number of values counted.

Author(s)

Henrik Bengtsson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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))

matrixStats documentation built on May 31, 2017, 2:26 a.m.