all
Logical Sum and Product

Description

Gives a single logical value that is a function of the logical values that are input.

Usage

all(..., na.rm = FALSE)
any(..., na.rm = FALSE)

Arguments

... any number of arguments, each can be coerced to mode logical. Missing values (NA) are allowed.
na.rm a logical flag. If TRUE, missing values are removed before computation. The default is FALSE. You must specify this argument in the na.rm = TRUE/FALSE form.
Value
returns a logical value.
allevaluates to TRUE if all elements of all arguments are TRUE. all evaluates to FALSE if any elements of any arguments are FALSE. In all other cases (that is, combinations of NA and TRUE), the result is NA. If arguments are of length 0, all returns TRUE.
anyevaluates to TRUE if any of the elements of any of the arguments is TRUE. any evaluates to FALSE if all elements are FALSE. In all other cases (that is, combinations of NA and FALSE), the result is NA. If all of the arguments are of length 0, any returns FALSE.
See Also
Logic.
Examples
x <- c(-2, -1, 0, 1, 2)
if(all(x < 0)) x <- sqrt(x)

any(x == 0) # [1] TRUE

all() # [1] TRUE any() # [1] FALSE all(logical(0)) # [1] TRUE any(logical(0)) # [1] FALSE

all(FALSE) #[1] FALSE

Package base version 6.0.0-69
Package Index