irepeat {itertools2} | R Documentation |
Iterator that returns an object indefinitely
Description
Constructs an iterator that returns an object over and over again.
Usage
irepeat(object, times = NULL)
Arguments
object |
object to return indefinitely. |
times |
the number of times |
Details
Runs indefinitely unless the times
argument is specified. Used as
argument to imap
for invariant function
parameters. Also used with izip
to create constant
fields in a tuple record.
Value
iterator that returns object
Examples
it <- irepeat(42)
iterators::nextElem(it)
iterators::nextElem(it)
iterators::nextElem(it)
# Further calls to iterators::nextElem(it) will repeat 42
it2 <- irepeat(42, times=4)
iterators::nextElem(it2)
iterators::nextElem(it2)
iterators::nextElem(it2)
iterators::nextElem(it2)
# The object can be a data.frame, matrix, etc
it3 <- irepeat(iris, times=4)
iterators::nextElem(it3)
iterators::nextElem(it3)
iterators::nextElem(it3)
iterators::nextElem(it3)
[Package itertools2 version 0.1.1 Index]