Boolean NEGATION '!', AND '&', OR '|' and EXCLUSIVE OR xor', see Logic
.
# S3 method for default
xor(x, y)# S3 method for logical
xor(x, y)
# S3 method for bit
!(x)
# S3 method for bit
&(e1, e2)
# S3 method for bit
|(e1, e2)
# S3 method for bit
==(e1, e2)
# S3 method for bit
!=(e1, e2)
# S3 method for bit
xor(x, y)
# S3 method for bitwhich
!(x)
# S3 method for bitwhich
&(e1, e2)
# S3 method for bitwhich
|(e1, e2)
# S3 method for bitwhich
==(e1, e2)
# S3 method for bitwhich
!=(e1, e2)
# S3 method for bitwhich
xor(x, y)
# S3 method for booltype
&(e1, e2)
# S3 method for booltype
|(e1, e2)
# S3 method for booltype
==(e1, e2)
# S3 method for booltype
!=(e1, e2)
# S3 method for booltype
xor(x, y)
xor(x, y)
An object of class booltype
or logical
a is.booltype
vector
a is.booltype
vector
a is.booltype
vector
a is.booltype
vector
default
: default method for xor
bit
: bit
method for !
bit
: bit
method for &
bit
: bit
method for |
bit
: bit
method for ==
bit
: bit
method for !=
bit
: bit
method for xor
bitwhich
: bitwhich
method for !
bitwhich
: bitwhich
method for &
bitwhich
: bitwhich
method for |
bitwhich
: bitwhich
method for ==
bitwhich
: bitwhich
method for !=
bitwhich
: bitwhich
method for xor
booltype
: booltype
method for &
booltype
: booltype
method for |
booltype
: booltype
method for ==
booltype
: booltype
method for !=
booltype
: booltype
method for xor
Jens Oehlschlägel
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)
booltypes
, Logic
x <- c(FALSE, FALSE, FALSE, NA, NA, NA, TRUE, TRUE, TRUE)
y <- c(FALSE, NA, TRUE, FALSE, NA, TRUE, FALSE, NA, TRUE)
x|y
x|as.bit(y)
x|as.bitwhich(y)
x|as.which(y)
x|ri(1,1,9)
Run the code above in your browser using DataLab