isplitIndices: Create an iterator of indices

Description Usage Arguments Value See Also Examples

View source: R/isplitIndices.R

Description

Create an iterator of chunks of indices from 1 to n. You can specify either the number of pieces, using the chunks argument, or the maximum size of the pieces, using the chunkSize argument.

Usage

1

Arguments

n

Maximum index to generate.

...

Passed as the second and subsequent arguments to idiv function. Currently, idiv accepts either a value for chunks or chunkSize.

Value

An iterator that returns vectors of indices from 1 to n.

See Also

idiv, isplitVector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Return indices from 1 to 17 in vectors no longer than five
it <- ihasNext(isplitIndices(17, chunkSize=5))
while (hasNext(it)) {
  print(nextElem(it))
}

# Return indices from 1 to 7 in four vectors
it <- ihasNext(isplitIndices(7, chunks=4))
while (hasNext(it)) {
  print(nextElem(it))
}

itertools documentation built on May 21, 2017, 3:52 a.m.

Search within the itertools package
Search all R packages, documentation and source code