Macaulay2 » Documentation
Packages » RInterface » RObject » RObject ? RObject
next | previous | forward | backward | up | index | toc

RObject ? RObject -- comparison of R objects

Description

The standard comparison operators work on R objects.

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 = true
i4 : x < y

o4 = false
i5 : x >= y

o5 = true
i6 : x <= y

o6 = false

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

i7 : x > 2

o7 = true
i8 : 5 < y

o8 = 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.

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

o9 = [1] FALSE  TRUE  TRUE

o9 : RObject of type logical

Internally, these operators are implemented via Macaulay2's ? method, which returns <, >, ==, or incomparable.

See also

Ways to use this method:


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/RInterface/doc/relational.m2:93:0.