Learn R Programming

purrr (version 0.1.0)

every: Do every or some elements of a list satisfy a predicate?

Description

Do every or some elements of a list satisfy a predicate?

Usage

every(.x, .p, ...)

some(.x, .p, ...)

Arguments

.x
A list or vector.
.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
...
Additional arguments passed on to .f.

Value

  • Either TRUE or FALSE.

Examples

Run this code
x <- list(0, 1, TRUE)
x %>% every(identity)
x %>% some(identity)

y <- list(0:10, 5.5)
y %>% every(is.numeric)
y %>% every(is.integer)

Run the code above in your browser using DataLab