Description Usage Arguments Value See Also Examples
Any()
is a predicate functional that takes a predicate function
.f
and an iterable object .x
and:
iterates over each item i
in object .x
,
evaluates .f(i)
,
and ultimately returns TRUE if any items i
in object .x
evaluate as TRUE.
1 |
.x |
An iterable object. |
.f |
A predicate function. |
... |
Further arguments passed to the predicate function. |
na.rm |
A logical value indicating whether NA values should be stripped before the computation proceeds. |
A logical value indicating if any items evaluated as TRUE.
All
to test if all items in an object evaluate to TRUE.
Other predicate functionals: All
;
Reject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Examples
data(mtcars)
Any(mtcars, is.numeric) # TRUE
Any(mtcars, is.character) # FALSE
mtcars$am <- factor(mtcars$am)
Any(mtcars, is.numeric) # TRUE
Any(mtcars, is.factor) # TRUE
# Handles NAs and NULLs
Any(list(NA, "3", NULL), is.numeric) # FALSE
Any(list(NA, 3, NULL), is.numeric) # TRUE
Any(list(NA, "3", NULL, 5), is.numeric) #TRUE
# Use na.rm = TRUE to remove NULLS
Any(list(NA, FALSE), Identity) # NA
Any(list(NA, FALSE), Identity, na.rm = TRUE) # FALSE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.