i_recycle | R Documentation |
Create an iterator that recycles a specified iterable. On the first repeat the iterable is buffered into memory until it finishes, then we repeat the same sequence of values.
i_recycle(iterable, times = Inf, ...)
iterable |
The iterable to recycle. |
times |
integer. Number of times to recycle the values .
Default value of |
... |
Further arguments will be passed along to iteror. |
Originally from the itertools
package.
an iteror recycling the values from the underlying iterable.
# Recycle over 'a', 'b', and 'c' three times
i <- i_recycle(letters[1:3], 3)
as.character(i)
it <- i_recycle(1:3)
nextOr(it, NA) # 1
nextOr(it, NA) # 2
nextOr(it, NA) # 3
nextOr(it, NA) # 1
nextOr(it, NA) # 2
nextOr(it, NA) # 3
nextOr(it, NA) # 1
it2 <- i_recycle(1:3, times=2)
as.list(it2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.