Learn R Programming

tidyna (version 0.4.0)

logical-functions: NA-aware Logical Functions

Description

Drop-in replacements for any() and all() that default to na.rm = TRUE.

Usage

any(x, na.rm = TRUE, all_na = NULL, ...)

all(x, na.rm = TRUE, all_na = NULL, ...)

Value

A single logical value.

Arguments

x

A logical vector.

na.rm

Logical. Should missing values be removed? Default TRUE.

all_na

Character. What to do when all values are NA: "error" (default) throws an error, "base" returns what base R does with na.rm = TRUE (FALSE for any(), TRUE for all()), "na" returns NA. If NULL, uses getOption("tidyna.all_na", "error").

...

Additional arguments passed to the base function.

Examples

Run this code
x <- c(TRUE, NA, FALSE)
any(x)
all(x)

Run the code above in your browser using DataLab