
Last chance! 50% off unlimited learning
Sale ends in
iarray(X, MARGIN, ..., chunks, chunkSize, drop, idx=lapply(dim(X), function(i) TRUE))
MARGIN
is greater than one, the resulting iterator
will generate iterators which is particularly useful with nested
foreach loops.MARGIN
.
A single value will be recycled for each dimension if MARGIN
has more than one value.MARGIN
.
A single value will be recycled for each dimension if MARGIN
has more than one value.FALSE
if either chunks
or
chunkSize
is specified, otherwise to TRUE
.apply
# 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)
Run the code above in your browser using DataLab