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

relational operators on RObjects -- relational operators on R objects

The relational operators ==, !=, >, <, >=, and <= do the expected thing when comparing two RObject's.

i1 : x = RObject 5

o1 = [1] 5

o1 : RObject of type integer
i2 : y = RObject 2

o2 = [1] 2

o2 : RObject of type integer
i3 : x == y

o3 = false
i4 : x != y

o4 = true
i5 : x > y

o5 = true
i6 : x < y

o6 = false
i7 : x >= y

o7 = true
i8 : x < y

o8 = false

One of the operands may be a Macaulay2 object. It will be converted to an RObject before the operation is performed.

i9 : x > 2

o9 = true
i10 : 5 < y

o10 = false

Note that these operators return Macaulay2 Boolean objects and not R logical vectors. In particular, they are not useful for comparing vectors of length greater than 1. To do this, you may use RFunction to get the corresponding R operator as a function.

i11 : (RFunction ">=")({1, 2, 3}, {2, 2, 2})

o11 = [1] FALSE  TRUE  TRUE

o11 : RObject of type logical