Array: make vector positions from array index
Make vector positions from a (non-symmetric) array index respecting dim and dimorder
arrayIndex2vectorIndex(x, dim = NULL, dimorder = NULL, vw = NULL)
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))'.
a vector of indices in seq_len(prod(dim))
(or seq_len(prod(colSums(vw)))
)
Jens Oehlschlägel
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.