detect: Find the value or position of the first match.
Description
Find the value or position of the first match.
Usage
detect(.x, .p, ..., .right = FALSE)
detect_index(.x, .p, ..., .right = FALSE)
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.
.right
If FALSE, the default, starts at the beginnging
of the vector and move towards the end; if TRUE, starts at the end
of the vector and moves towards the beginning.
Value
detect the value of the first item that matches the
predicate; detect_index the position of the matching item.
If not found, detect returns NULL and detect_index
returns 0.