gt: Compare multiple vectors

View source: R/lgl2.R

gtR Documentation

Compare multiple vectors

Description

Compare multiple vectors

Usage

gt(...)

lt(...)

eq(...)

neq(...)

leq(...)

geq(...)

x %>>% y

x %<<% y

x %==% y

x %!=% y

x %<=% y

x %>=% y

Arguments

x, y, ...

Vectors, typically numerical, to be compared.

Value

A logical vector. For the operator, a last_y attribute stores the last RHS values from the comparisons (strip away with as.vector()). See examples.

Examples

x <- c(1, 3, 1, 1, 2)
y <- c(2, 2, 1, 1, 1)
z <- c(3, 1, 1, 2, 1)


lt(x, y, z) # >
eq(x, y, z) # ==
neq(x, y, z) # !=
leq(x, y, z) # <=
geq(x, y, z) # >=

gt(x, y, z) # <

# same as
x %>>% y %>>% z

# same as
x > y & y > z

# Operators can be mixed!

x %>>% y %==% z

# Or broken
(l1 <- x %>>% y)

(l2 <- l1 %==% z)

# same as
x > y & y == z

as.vector(l2)


mattansb/MSBMisc documentation built on March 22, 2023, 6:02 p.m.