itertools-package: The itertools Package

Description Details


The itertools package provides a variety of functions used to create iterators, as defined by REvolution Computing's iterators package. Many of the functions are patterned after functions of the same name in the Python itertools module, including chain, product, izip, ifilter, etc. In addition, a number of functions were inspired by utility functions in the snow package, such as isplitRows, isplitCols, and isplitIndices.

There are also several utility functions that were contributed by Hadley Wickham that aid in writing iterators. These include is.iterator, end_iterator, iteration_has_ended, and new_iterator.


More information is available on the following topics:

isplitVector splits, or slices, a vector into shorter segments
isplitCols splits a matrix column-wise
isplitRows splits a matrix row-wise
isplitIndices iterate over “chunks” of indices from 1 to n
chain chain multiple iterators together into one iterator
enumerate create an enumeration from an iterator
ichunk create lists of values from an iterator to aid manual chunking
ihasNext add a hasNext method to an iterator
ifilter only return values for which a predicate function returns true
ifilterfalse only return values for which a predicate function returns false
ilimit limit, or truncate, an iterator
ireadBin reads from a binary connection
irep an iterator version of the rep function
irepeat a simple repeating value iterator
izip zip together multiple iterators
product zip together multiple iterators in cartesian product fashion
recycle recycle values from an iterator repeatedly
timeout iterate for a specified number of seconds
is.iterator indicates if an object is an iterator
end_iteration throws an exception to signal end of iteration
iteration_has_ended tests an exception to see if iteration has ended
new_iterator creates a new iterator object

For a complete list of functions with individual help pages, use library(help="itertools").

itertools documentation built on May 31, 2017, 4:48 a.m.

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