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 giving the dimension number 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.
Note
In the future, this function might be extended to allow a vector of integers for the MARGIN argument, as in the apply function.
See Also
apply, col, rep, row, split.
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,] 
Package base version 4.0.0-28
Package Index