View source: R/every-some-none.R
every | R Documentation |
some()
returns TRUE
when .p
is TRUE
for at least one element.
every()
returns TRUE
when .p
is TRUE
for all elements.
none()
returns TRUE
when .p
is FALSE
for all elements.
every(.x, .p, ...)
some(.x, .p, ...)
none(.x, .p, ...)
.x |
A list or vector. |
.p |
A predicate function (i.e. a function that returns either
|
... |
Additional arguments passed on to |
A logical vector of length 1.
x <- list(0:10, 5.5)
x |> every(is.numeric)
x |> every(is.integer)
x |> some(is.integer)
x |> none(is.character)
# Missing values are propagated:
some(list(NA, FALSE), identity)
# If you need to use these functions in a context where missing values are
# unsafe (e.g. in `if ()` conditions), make sure to use safe predicates:
if (some(list(NA, FALSE), rlang::is_true)) "foo" else "bar"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.