LogicBit {bit} | R Documentation |
Boolean 'negation', 'and', 'or' and 'exclusive or'.
## S3 method for class 'bit' !x ## S3 method for class 'bitwhich' !x ## S3 method for class 'bit' e1 & e2 ## S3 method for class 'bitwhich' e1 & e2 ## S3 method for class 'bit' e1 | e2 ## S3 method for class 'bitwhich' e1 | e2 ## S3 method for class 'bit' e1 == e2 ## S3 method for class 'bitwhich' e1 == e2 ## S3 method for class 'bit' e1 != e2 ## S3 method for class 'bitwhich' e1 != e2 xor(x, y) ## Default S3 method: xor(x, y) ## S3 method for class 'bit' xor(x, y) ## S3 method for class 'bitwhich' xor(x, y)
x |
a bit vector (or one logical vector in binary operators) |
y |
a bit vector or an logical vector |
e1 |
a bit vector or an logical vector |
e2 |
a bit vector or an logical vector |
Binary operators and function xor
can combine 'bit' objects and 'logical' vectors.
They do not recycle, thus the lengths of objects must match. Boolean operations on bit vectors are extremely fast
because they are implemented using C's bitwise operators. If one argument is 'logical' it is converted to 'bit'.
Binary operators and function xor
can combine 'bitwhich' objects and other vectors.
They do not recycle, thus the lengths of objects must match. Boolean operations on bitwhich vectors are fast
if the distribution of TRUE and FALSE is very asymetric. If one argument is not 'bitwhich' it is converted to 'bitwhich'.
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)
An object of class 'bit' (or 'bitwhich')
Jens Oehlschlägel
x <- as.bit(c(FALSE, FALSE, FALSE, NA, NA, NA, TRUE, TRUE, TRUE)) yl <- c(FALSE, NA, TRUE, FALSE, NA, TRUE, FALSE, NA, TRUE) y <- as.bit(yl) !x x & y x | y xor(x, y) x != y x == y x & yl x | yl xor(x, yl) x != yl x == yl x <- as.bitwhich(c(FALSE, FALSE, FALSE, NA, NA, NA, TRUE, TRUE, TRUE)) yl <- c(FALSE, NA, TRUE, FALSE, NA, TRUE, FALSE, NA, TRUE) y <- as.bitwhich(yl) !x x & y x | y xor(x, y) x != y x == y x & yl x | yl xor(x, yl) x != yl x == yl