Description Usage Arguments See Also Examples
Create an iterator over an array.
1 2 |
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. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 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)
|
Loading required package: iterators
[[1]]
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[[2]]
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
[[3]]
[,1] [,2] [,3]
[1,] 13 15 17
[2,] 14 16 18
[[4]]
[,1] [,2] [,3]
[1,] 19 21 23
[2,] 20 22 24
[[1]]
, , 1
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
, , 2
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
[[2]]
, , 1
[,1] [,2] [,3]
[1,] 13 15 17
[2,] 14 16 18
, , 2
[,1] [,2] [,3]
[1,] 19 21 23
[2,] 20 22 24
, , 1
[,1] [,2] [,3] [,4]
[1,] 1 5 9 13
[2,] 2 6 10 14
[3,] 3 7 11 15
[4,] 4 8 12 16
, , 2
[,1] [,2] [,3] [,4]
[1,] 17 21 25 29
[2,] 18 22 26 30
[3,] 19 23 27 31
[4,] 20 24 28 32
, , 1
[,1] [,2] [,3] [,4]
[1,] 33 37 41 45
[2,] 34 38 42 46
[3,] 35 39 43 47
[4,] 36 40 44 48
, , 2
[,1] [,2] [,3] [,4]
[1,] 49 53 57 61
[2,] 50 54 58 62
[3,] 51 55 59 63
[4,] 52 56 60 64
, , 1
[,1] [,2]
[1,] 1 5
[2,] 2 6
[3,] 3 7
[4,] 4 8
, , 2
[,1] [,2]
[1,] 17 21
[2,] 18 22
[3,] 19 23
[4,] 20 24
, , 1
[,1] [,2]
[1,] 9 13
[2,] 10 14
[3,] 11 15
[4,] 12 16
, , 2
[,1] [,2]
[1,] 25 29
[2,] 26 30
[3,] 27 31
[4,] 28 32
, , 1
[,1] [,2]
[1,] 33 37
[2,] 34 38
[3,] 35 39
[4,] 36 40
, , 2
[,1] [,2]
[1,] 49 53
[2,] 50 54
[3,] 51 55
[4,] 52 56
, , 1
[,1] [,2]
[1,] 41 45
[2,] 42 46
[3,] 43 47
[4,] 44 48
, , 2
[,1] [,2]
[1,] 57 61
[2,] 58 62
[3,] 59 63
[4,] 60 64
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.