irep {itertools2} | R Documentation |
Iterator that replicates elements of an iterable object
Description
Constructs an iterator that replicates the values of an object
.
Usage
irep(object, times = 1, length.out = NULL, each = NULL)
irep_len(object, length.out = NULL)
Arguments
object |
object to return indefinitely. |
times |
the number of times to repeat each element in |
length.out |
non-negative integer. The desired length of the iterator |
each |
non-negative integer. Each element is repeated |
Details
This function is intended an iterable version of the standard
rep
function. However, as exception, the recycling
behavior of rep
is intentionally not implemented.
Value
iterator that returns object
Examples
it <- irep(1:3, 2)
unlist(as.list(it)) == rep(1:3, 2)
it2 <- irep(1:3, each=2)
unlist(as.list(it2)) == rep(1:3, each=2)
it3 <- irep(1:3, each=2, length.out=4)
as.list(it3)
[Package itertools2 version 0.1.1 Index]