Macaulay2 » Documentation
Packages » RInterface :: logical operators on RObjects
next | previous | forward | backward | up | index | toc

logical operators on RObjects -- logical operators on R objects

The logical operators not, and, or, and xor are supported when working with logical vectors.

i1 : not RObject true

o1 = [1] FALSE

o1 : RObject of type logical
i2 : RObject true and RObject false

o2 = [1] FALSE

o2 : RObject of type logical
i3 : RObject true or RObject false

o3 = [1] TRUE

o3 : RObject of type logical
i4 : RObject true xor RObject false

o4 = [1] TRUE

o4 : RObject of type logical

When a logical vector contains multiple elements, the output will also contain multiple elements.

i5 : RObject {true, true, false, false} and RObject {true, false, true, false}

o5 = [1]  TRUE FALSE FALSE FALSE

o5 : RObject of type logical

For the binary operators, one of the operands may be a Macaulay2 object. It will be converted to an RObject before the operation is performed.

i6 : RObject {true, true, false, false} or {true, false, true, false}

o6 = [1]  TRUE  TRUE  TRUE FALSE

o6 : RObject of type logical
i7 : {true, true, false, false} xor RObject {true, false, true, false}

o7 = [1] FALSE  TRUE  TRUE FALSE

o7 : RObject of type logical

Note that and and or use R's & and |, respectively.