all(..., na.rm = FALSE) any(..., na.rm = FALSE)
... | 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. |
all | evaluates 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. |
any | evaluates 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. |
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