Return TRUE if n is an integer evenly divisibly by 2.

isEven(n)

Arguments

n

A numeric vector.

Value

A logical vector the same length as n. TRUE if n is an integer and is even, FALSE if n is an integer and not even, NA otherwise.

Details

Test whether elements of a numeric vector are even. For whole numbers return TRUE or FALSE. For decimals return NA.

Author

David Braze davebraze@gmail.com

Examples

n <- 1:10 isEven(n)
#> [1] FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE
m <- seq(1, 10, .5) isEven(m)
#> [1] FALSE NA TRUE NA FALSE NA TRUE NA FALSE NA TRUE NA #> [13] FALSE NA TRUE NA FALSE NA TRUE