vunion: Returns the union of its inputs including repeated elements.

Description Usage Arguments Value Author(s) See Also Examples

Description

The base::union function removes duplicates per algebraic set theory. vunion does not, and so returns as many duplicate elements as are in either input vector (not the sum of their inputs.) In short, vunion is the same as vintersect(x,y) + vsetdiff(x,y) + vsetdiff(y,x).

Usage

1
vunion(x, y, multiple = TRUE)

Arguments

x

A vector or an object which can be coerced to a vector

y

A vector or an object which can be coerced to a vector

multiple

Should repeated "multiple" items be returned? Default is TRUE; if set to FALSE, vunion acts like the base::vunion function.

Value

A vector of the union of the two input vectors. If multiple is set to FALSE then the value returned is the same as base::union.

Author(s)

Carl Witthoft

See Also

union, the CRAN package sets

Examples

1
2
3
4
5
x <- c(1:5,3,3,3,2,NA,NA)
y<- c(2:5,4,3,NA)
vunion(x,y)
vunion(x,y,multiple=FALSE) 
union(x,y) #same as previous line

Example output

 [1]  2  3  3  4  5 NA  1  3  3  2 NA  4
[1]  2  3  4  5 NA  1
[1]  1  2  3  4  5 NA

vecsets documentation built on March 8, 2021, 1:13 a.m.