i_unique | R Documentation |
Constructs an iterator that extracts each unique element in turn from an
iterable object
. Order of the elements is maintained. This function is
an iterator analogue to unique.
i_unique(object, digest = rlang::hash, ...)
object |
an iterable object |
digest |
Optionally specify a custom hash function
(e.g. |
... |
Extra arguments are forwarded to iteror. |
NOTE: In order to determine whether an element is unique, a list of previous unique elements is stored. In doing so, the list can potentially become large if there are a large number of unique elements.
an iterator that returns only the unique elements from
object
i_dedupe
it <- i_chain(rep(1, 4), rep(2, 5), 4:7, 2)
as.list(i_unique(it)) # 1 2 4 5 6 7
it2 <- iterators::iter(c('a', 'a', "A", "V"))
as.list(i_unique(it2)) # a A V
x <- as.character(gl(5, 10))
it_unique <- i_unique(x)
as.list(it_unique) # 1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.