Description Usage Arguments Details Value See Also Examples
Performs set union, intersection, (asymmetric!) difference, equality and membership on two vectors.
1 2 3 4 5 6 |
x, y, el, set |
vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values. |
Each of union
, intersect
, setdiff
and
setequal
will discard any duplicated values in the arguments,
and they apply as.vector
to their arguments (and so
in particular coerce factors to character vectors).
is.element(x, y)
is identical to x %in% y
.
A vector of the same mode
as x
or y
for
setdiff
and intersect
, respectively, and
of a common mode for union
.
A logical scalar for setequal
and a logical of the same
length as x
for is.element
.
‘plotmath’ for the use of union
and
intersect
in plot annotation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | (x <- c(sort(sample(1:20, 9)), NA))
(y <- c(sort(sample(3:23, 7)), NA))
union(x, y)
intersect(x, y)
setdiff(x, y)
setdiff(y, x)
setequal(x, y)
## True for all possible x & y :
setequal( union(x, y),
c(setdiff(x, y), intersect(x, y), setdiff(y, x)))
is.element(x, y) # length 10
is.element(y, x) # length 8
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.