xor, isTRUE

Apply an exclusive-or check across two vectors using xor. Use isTRUE to check whether an R object is exactly a vector of length 1 that has value TRUE.
xor(x, y)
  • x – A vector that can be coerced to logical values.
  • y – A vector that can be coerced to logical values.
isTRUE(x)
  • x – An R object.

Example. A couple simple examples applying xor followed by an application of xor to two vectors, where it returns the element-wise exclusive-or check. Next, several examples of isTRUE are shown. isTRUE will only return TRUE when its argument is exactly TRUE.
> 
> xor(TRUE, TRUE)
[1] FALSE
> 
> xor(1, 0)
[1] TRUE
> 
> xor(c(TRUE, TRUE, FALSE, FALSE),
+     c(TRUE, FALSE, TRUE, FALSE))
[1] FALSE  TRUE  TRUE FALSE
> 
> 
> isTRUE(1)
[1] FALSE
> 
> isTRUE(TRUE)
[1] TRUE
> 
> isTRUE(FALSE)
[1] FALSE
> 
> isTRUE(list(TRUE))
[1] FALSE
> 

Leave a Reply