Determine if a number is odd or even.
is.odd(x) is.even(x)
x | A numeric vector. |
---|
A logical vector of the same length as x.
## Individual values is.odd(1)#> [1] TRUEis.odd(2)#> [1] FALSEis.even(3)#> [1] FALSEis.even(4)#> [1] TRUE## Vector of values d <- 1:8 data.frame(d,odd=is.odd(d),even=is.even(d))#> d odd even #> 1 1 TRUE FALSE #> 2 2 FALSE TRUE #> 3 3 TRUE FALSE #> 4 4 FALSE TRUE #> 5 5 TRUE FALSE #> 6 6 FALSE TRUE #> 7 7 TRUE FALSE #> 8 8 FALSE TRUE