Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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 logical element in the inner lists. Only those elements where .p evaluates to TRUE will be modified.

Value

A new predicate function.

Examples

negate("x")
negate(is.null)
negate(~ .x > 0)

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

purrr

Functional Programming Tools

v0.3.4
GPL-3 | file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.