iarray {itertools} | R Documentation |
Create an iterator over an array
Description
Create an iterator over an array.
Usage
iarray(X, MARGIN, ..., chunks, chunkSize, drop,
idx=lapply(dim(X), function(i) TRUE))
Arguments
X |
Array to iterate over. |
MARGIN |
Vector of subscripts to iterate over. Note that if
the length of |
... |
Used to force subsequent arguments to be specified by name. |
chunks |
Number of elements that the iterator should generate.
This can be a single value or a vector the same length as |
chunkSize |
The maximum size Number of elements that the iterator
should generate.
This can be a single value or a vector the same length as |
drop |
Should dimensions of length 1 be dropped in the generated
values? It defaults to |
idx |
List of indices used to generate a call object. |
See Also
Examples
# Iterate over matrices in a 3D array
x <- array(1:24, c(2,3,4))
as.list(iarray(x, 3))
# Iterate over subarrays
as.list(iarray(x, 3, chunks=2))
x <- array(1:64, c(4,4,4))
it <- iarray(x, c(2,3), chunks=c(1,2))
jt <- nextElem(it)
nextElem(jt)
jt <- nextElem(it)
nextElem(jt)
it <- iarray(x, c(2,3), chunks=c(2,2))
jt <- nextElem(it)
nextElem(jt)
nextElem(jt)
jt <- nextElem(it)
nextElem(jt)
nextElem(jt)