boolean_ops: Boolean Operators

Description Usage Arguments Details Value Examples

Description

These provide better logical operators for catching TRUE and FALSE statements in the presence of 'NA' values. These return 'NA' values as 'FALSE' and thus no 'na.rm' argument is not necessary.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Arguments

x

A vector of logical values

...

Additional arguments sent to methods (not used)

Details

The functions [is_true()] and [is_false()] are vectorized and will return a logical vector of the same length as the input 'x' denoting whether or not the values are 'TRUE' or 'FALSE', respectively. The 'all_*()' and 'any_*()' functions apply the vectorized functions and return values of 'TRUE' or 'FALSE'.

Specialized 'any_*_x()' and 'all_*_x()' apply exclusivity to the evaluations. These will return 'NA' is all the values are 'NA' to designate an incompatibility of values. This is useful for when you do not want to apply an evaluation in the _absence_ of data.

Value

Either a vector of logical values or a single logical values (see details).

Examples

1
2
3
4
5
6
7
8
x <- c(TRUE, NA, FALSE)
is_true(x)     ##  TRUE FALSE FALSE
is_false(x)    ## FALSE FALSE  TRUE
all_true(x)    ## FALSE
all_true(NA)   ## FALSE
all_true_x(NA) ## NA
any_true_x(x)  ## TRUE
any_true_x(NA) ## NA

jmbarbone/dirtyr documentation built on Sept. 23, 2020, 4:05 a.m.