sets {base}R Documentation

Set Operations

Description

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

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.

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]