set_operations: Set operators

Description Usage Arguments Value Examples

Description

Binary operators for set inclusion, intersection, union, asymmetric and symmetric difference, and equality, just like %in%.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x %c% y

x %n% y

x %u% y

x %-% y

x %(-)% y

x %==% y

Arguments

x, y

The same as for union(), intersect(), setdiff(), and setequal().

Value

Return values for intersection, union, difference, and equality are the same as their base counterparts. Inclusion returns a length 1 logical that is TRUE if x is a subset (or equal to) y, FALSE otherwise. The symmetric difference returns the elements of x and y that are not members of both x and y.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
A <- 2:4
B <- 1:3
C <- 3:5

A %n% B %n% C

A %u% B %u% C

(A %n% B %n% C) %c% (A %u% B %u% C)

(A %-% (B %u% C)) %==% ((A %-% B) %n% (A %-% C))

A %(-)% NULL %==% A

marberts/smart documentation built on March 9, 2021, 5:31 p.m.