irep: Create a repeating iterator

Description Usage Arguments See Also Examples

View source: R/irep.R

Description

Create an iterator version of the rep function.

Usage

1
irep(iterable, times, length.out, each)

Arguments

iterable

The iterable to iterate over repeatedly.

times

A vector giving the number of times to repeat each element if the length is greater than one, or to repeat all the elements if the length is one. This behavior is less strict than rep since the length of an iterable isn't generally known.

length.out

non-negative integer. The desired length of the output iterator.

each

non-negative integer. Each element of the iterable is repeated each times.

See Also

rep

Examples

1
2
3
4
5
6
7
unlist(as.list(irep(1:4, 2)))
unlist(as.list(irep(1:4, each=2)))
unlist(as.list(irep(1:4, c(2,2,2,2))))
unlist(as.list(irep(1:4, c(2,1,2,1))))
unlist(as.list(irep(1:4, each=2, len=4)))
unlist(as.list(irep(1:4, each=2, len=10)))
unlist(as.list(irep(1:4, each=2, times=3)))


itertools documentation built on May 21, 2017, 3:52 a.m.
Search within the itertools package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.