R: Are Some Values True? (original) (raw)
any {base} | R Documentation |
---|
Description
Given a set of logical vectors, is at least one of the values true?
Usage
any(..., na.rm = FALSE)
Arguments
... | zero or more logical vectors. Other objects of zero length are ignored, and the rest are coerced to logical ignoring any class. |
---|---|
na.rm | logical. If true NA values are removed before the result is computed. |
Details
This is a generic function: methods can be defined for it directly or via the [Summary](../../base/help/S3groupGeneric.html)
group generic. For this to work properly, the arguments ...
should be unnamed, and dispatch is on the first argument.
Coercion of types other than integer (raw, double, complex, character, list) gives a warning as this is often unintentional.
This is a primitive function.
Value
The value is a logical vector of length one.
Let x
denote the concatenation of all the logical vectors in...
(after coercion), after removing NA
s if requested byna.rm = TRUE
.
The value returned is TRUE
if at least one of the values inx
is TRUE
, and FALSE
if all of the values inx
are FALSE
(including if there are no values). Otherwise the value is NA
(which can only occur if na.rm = FALSE
and ...
contains no TRUE
values and at least oneNA
value).
S4 methods
This is part of the S4 [Summary](../../methods/html/S4groupGeneric.html)
group generic. Methods for it must use the signaturex, ..., na.rm
.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language. Wadsworth & Brooks/Cole.
See Also
[all](../../base/help/all.html)
, the ‘complement’ of any
.
Examples
range(x <- sort(round(stats::rnorm(10) - 1.2, 1)))
if(any(x < 0)) cat("x contains negative values\n")
[Package _base_ version 4.6.0 Index]