slice.index
Slice Identification in an Array
Description
Returns an array filled with integers, each of which identifies
where in the current slice it is. This is a generalization of
the row and col functions: row(x) can be expressed as
slice.index(x,1) and col(x) can be expressed as slice.index(x,2).
Usage
slice.index(x, MARGIN)
Arguments
x |
An array or data.frame. If x has no dimensions, it is considered to be
a one dimensional array.
|
MARGIN |
An integer vector giving the dimension numbers by which to slice.
|
Value
returns an array with the same dimensions as x.
The subarray result[...,i,...], where i is the MARGINth dimension
is filled with the value i.
See Also
Examples
x <- array(data=101:124, dim=c(4, 3, 2))
slice.index(x, 1)
slice.index(x, 3)
split(x, f = slice.index(x, 2)) # compare to x[,1,], x[,2,], x[,3,]
slice.index(x, c(3,1))