arrayIndex2vectorIndex: Array: make vector positions from array index

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/array.R

Description

Make vector positions from a (non-symmetric) array index respecting dim and dimorder

Usage

1

Arguments

x

an n by m matrix with n m-dimensional array indices

dim

NULL or dim

dimorder

NULL or dimorder

vw

NULL or integer vector[3] or integer matrix[3,m], see details

Details

The fastest rotating dimension is dim[dimorder[1]], then dim[dimorder[2]], and so forth.
The parameters 'x' and 'dim' may refer to a subarray of a larger array, in this case, the array indices 'x' are interpreted as 'vw[1,] + x' within the larger array 'as.integer(colSums(vw))'.

Value

a vector of indices in 1:prod(dim) (or 1:prod(colSums(vw)))

Author(s)

Jens Oehlschl<c3><a4>gel

See Also

array2vector, vectorIndex2arrayIndex

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  x <- matrix(1:12, 3, 4)
  x
  arrayIndex2vectorIndex(cbind(as.vector(row(x)), as.vector(col(x)))
  , dim=dim(x))
  arrayIndex2vectorIndex(cbind(as.vector(row(x)), as.vector(col(x)))
  , dim=dim(x), dimorder=2:1)
  matrix(1:30, 5, 6)
  arrayIndex2vectorIndex(cbind(as.vector(row(x)), as.vector(col(x)))
  , vw=rbind(c(0,1), c(3,4), c(2,1)))
  arrayIndex2vectorIndex(cbind(as.vector(row(x)), as.vector(col(x)))
  , vw=rbind(c(0,1), c(3,4), c(2,1)), dimorder=2:1)

kindlychung/ff documentation built on May 20, 2019, 9:58 a.m.