Description Usage Arguments Value See Also Examples
Create an iterator that splits a vector into smaller pieces.
You can specify either the number of pieces, using the chunks
argument, or the maximum size of the pieces, using the chunkSize
argument.
1 | isplitVector(x, ...)
|
x |
Vector to iterate over. Note that it doesn't need to be an atomic vector, so a list is acceptable. |
... |
Passed as the second and subsequent arguments to
|
An iterator that returns vectors of the same type as x
with one
or more elements from x
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Split the vector 1:10 into "chunks" with a maximum length of three
it <- ihasNext(isplitVector(1:10, chunkSize=3))
while (hasNext(it)) {
print(nextElem(it))
}
# Split the vector "letters" into four chunks
it <- ihasNext(isplitVector(letters, chunks=4))
while (hasNext(it)) {
print(nextElem(it))
}
# Get the first five elements of a list as a list
nextElem(isplitVector(as.list(letters), chunkSize=5))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.