i_dropwhile | R Documentation |
Constructs an iterator that drops elements from the iterable object
as
long as the predicate
function is true; afterwards, every element of
iterable
object is returned.
i_dropwhile(object, predicate, ...)
object |
an iterable object |
predicate |
a function that determines whether an element is |
... |
Further arguments forwarded to iteror. |
Because the iterator does not return any elements until the predicate
first becomes false, there may have a lengthy start-up time before elements
are returned.
An iteror object.
# Filters out numbers exceeding 3
not_too_large <- function(x) {
x <= 3
}
it <- i_dropwhile(1:8, not_too_large)
as.list(it)
# Same approach but uses an anonymous function
it2 <- i_dropwhile(seq(2, 20, by=2), function(x) x <= 10)
as.list(it2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.