Set Operations

Usage

union(x, y)
intersect(x, y)
setdiff(x, y)
is.element(x, y)

Arguments

x, y vectors (of the same type) contain a sequence of items with no duplicated values.

Description

Performs set union, intersection difference and membership on two vectors.

Details

Each of union, intersect and setdiff will remove any duplicated values in the arguments.

Value

A vector of the same type as y.

Author(s)

B. D. Ripley

Examples

x <- sample(1:20, 10)
y <- sample(3:23, 7)
union(x, y)
intersect(x, y)
setdiff(x, y)
is.element(y, x)


[Package Contents]