Boolean NEGATION '!', AND '&', OR '|' and EXCLUSIVE OR xor', see
Logic.
# Default S3 method
xor(x, y)
# S3 method for class 'logical'
xor(x, y)
# S3 method for class 'bit'
!x
# S3 method for class 'bit'
e1 & e2
# S3 method for class 'bit'
e1 | e2
# S3 method for class 'bit'
e1 == e2
# S3 method for class 'bit'
e1 != e2
# S3 method for class 'bit'
xor(x, y)
# S3 method for class 'bitwhich'
!x
# S3 method for class 'bitwhich'
e1 & e2
# S3 method for class 'bitwhich'
e1 | e2
# S3 method for class 'bitwhich'
e1 == e2
# S3 method for class 'bitwhich'
e1 != e2
# S3 method for class 'bitwhich'
xor(x, y)
# S3 method for class 'booltype'
e1 & e2
# S3 method for class 'booltype'
e1 | e2
# S3 method for class 'booltype'
e1 == e2
# S3 method for class 'booltype'
e1 != e2
# S3 method for class 'booltype'
xor(x, y)
xor(x, y)a is.booltype() vector
a is.booltype() vector
a is.booltype() vector
a is.booltype() vector
An object of class booltype() or logical()
The binary operators and function xor can now combine any is.booltype() vectors.
They now recycle if vectors have different length. If the two arguments have different
booltypes() the return value corresponds to the lower booltype() of the two.
Boolean operations on bit() vectors are extremely fast because they are
implemented using C's bitwise operators. Boolean operations on or bitwhich()
vectors are even faster, if they represent very skewed selections.
The xor function has been made generic and xor.default has
been implemented much faster than R's standard xor().
This was possible because actually boolean function xor and
comparison operator != do the same (even with NAs), and != is
much faster than the multiple calls in (x | y) & !(x & y)
xor(default): default method for xor()
xor(logical): logical() method for xor()
xor(bit): bit() method for xor()
xor(bitwhich): bitwhich() method for xor()
xor(booltype): booltype() method for xor()
`!`(bitwhich): bitwhich() method for !
& : bitwhich() method for &
| : bitwhich() method for |
== : bitwhich() method for ==
!= : bitwhich() method for !=
& : booltype() method for &
| : booltype() method for |
== : booltype() method for ==
!= : booltype() method for !=
x <- c(FALSE, FALSE, FALSE, NA, NA, NA, TRUE, TRUE, TRUE)
y <- c(FALSE, NA, TRUE, FALSE, NA, TRUE, FALSE, NA, TRUE)
x | y
#> [1] FALSE NA TRUE NA NA TRUE TRUE TRUE TRUE
x | as.bit(y)
#> [1] FALSE FALSE TRUE NA NA TRUE TRUE TRUE TRUE
x | as.bitwhich(y)
#> [1] FALSE FALSE TRUE NA NA TRUE TRUE TRUE TRUE
x | as.which(y)
#> [1] FALSE FALSE TRUE NA NA TRUE TRUE TRUE TRUE
x | ri(1, 1, 9)
#> [1] TRUE FALSE FALSE NA NA NA TRUE TRUE TRUE