async (version 0.0.0.9004)

async_filter: Keep or drop elements using an asyncronous predicate function

Description

async_filter keep the elements for which .p is true. (Tested via isTRUE(). async_reject is the opposite, it drops them.

Usage

async_filter(.x, .p, ...)

async_reject(.x, .p, ...)

Arguments

.x

A list or atomic vector.

.p

An asynchronous predicate function.

...

Additional arguments to the predicate function.

Value

A deferred value for the result.

See Also

Other async iterators: async_detect, async_every, async_map

Examples

Run this code
# NOT RUN {
## Filter out non-working URLs
afun <- async(function(urls) {
  test_url <- async_sequence(
     http_head, function(x) identical(x$status_code, 200L))
  async_filter(urls, test_url)
})
urls <- c("https://eu.httpbin.org/get",
          "https://eu.httpbin.org/status/404")
synchronise(afun(urls))
# }

Run the code above in your browser using DataCamp Workspace