Description Usage Arguments See Also Examples
Create an iterator that issues lists of values from the underlying iterable. This is useful for manually “chunking” values from an iterable.
1 |
iterable |
Iterable to iterate over. |
chunkSize |
Maximum number of values from |
mode |
Mode of the objects returned by the iterator. |
1 2 3 4 5 6 7 8 9 10 11 | # Split the vector 1:10 into "chunks" with a maximum length of three
it <- ihasNext(ichunk(1:10, 3))
while (hasNext(it)) {
print(unlist(nextElem(it)))
}
# Same as previous, but return integer vectors rather than lists
it <- ihasNext(ichunk(1:10, 3, mode='integer'))
while (hasNext(it)) {
print(nextElem(it))
}
|
Loading required package: iterators
[1] 1 2 3
[1] 4 5 6
[1] 7 8 9
[1] 10
[1] 1 2 3
[1] 4 5 6
[1] 7 8 9
[1] 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.