Learn R Programming

purrr (version 0.1.0)

negate: Negate a predicate function.

Description

Negate a predicate function.

Usage

negate(.p)

Arguments

.p
A single predicate function, a formula describing such a predicate function, or a logical vector of the same length as .x. Alternatively, if the elements of .x are themselves lists of objects, a string indicating the name of a lo

Value

  • A new predicate function.

Examples

Run this code
x <- zip_n(list(x = 1:10, y = rbernoulli(10)))
x %>% keep("y") %>% length()
x %>% keep(negate("y")) %>% length()
# Same as
x %>% discard("y") %>% length()

Run the code above in your browser using DataLab