Description Usage Arguments Details Value Examples
The resulting iterator aggregates elements from each of the iterables into a list from each iteration. Used for lock-step iteration over several iterables at a time.
1 | izip_longest(..., fill = NA)
|
... |
multiple arguments to iterate through in sequence |
fill |
the value used to replace missing values when the iterables in
|
Although similar to izip
, missing values are
replaced with fill
if the iterables are of uneven length, and
Iteration continues until the longest iterable is exhausted.
iterator that iterates through each argument in sequence
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | it <- izip_longest(x=1:3, y=4:6, z=7:9)
iterators::nextElem(it) # list(x=1, y=4, z=7)
iterators::nextElem(it) # list(x=2, y=5, z=8)
iterators::nextElem(it) # list(x=3, y=6, z=9)
it2 <- izip_longest(1:3, 4:8)
iterators::nextElem(it2) # list(1, 4)
iterators::nextElem(it2) # list(2, 5)
iterators::nextElem(it2) # list(3, 6)
iterators::nextElem(it2) # list(NA, 7)
iterators::nextElem(it2) # list(NA, 8)
it3 <- izip_longest(1:2, 4:7, levels(iris$Species), fill="w00t")
iterators::nextElem(it3) # list(1, 4, "setosa")
iterators::nextElem(it3) # list(2, 5, "versicolor")
iterators::nextElem(it3) # list("w00t", 6, "virginica")
iterators::nextElem(it3) # list("w00t", 7, "w00t")
|
$x
[1] 1
$y
[1] 4
$z
[1] 7
$x
[1] 2
$y
[1] 5
$z
[1] 8
$x
[1] 3
$y
[1] 6
$z
[1] 9
[[1]]
[1] 1
[[2]]
[1] 4
[[1]]
[1] 2
[[2]]
[1] 5
[[1]]
[1] 3
[[2]]
[1] 6
[[1]]
[1] NA
[[2]]
[1] 7
[[1]]
[1] NA
[[2]]
[1] 8
[[1]]
[1] 1
[[2]]
[1] 4
[[3]]
[1] "setosa"
[[1]]
[1] 2
[[2]]
[1] 5
[[3]]
[1] "versicolor"
[[1]]
[1] "w00t"
[[2]]
[1] 6
[[3]]
[1] "virginica"
[[1]]
[1] "w00t"
[[2]]
[1] 7
[[3]]
[1] "w00t"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.