vsetdiff: Find all elements in first argument which are not in second...

Description Usage Arguments Value Author(s) See Also Examples

Description

Finds all elements in first argument which are not in the second argument. Unlike the base::setdiff function, if the vectors have repeated elements in common, only the "excess" number of a given element are returned.

Usage

1
vsetdiff(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, vintersect acts like the base::intersect function.

Value

A vector of all elements in x which are not in y. If multiple=FALSE is set, only unique values are returned.

Author(s)

Carl Witthoft

See Also

setdiff, the CRAN package sets

Examples

1
2
3
4
5
6
x <- c(1:5,3,3,3,2,NA,NA)
y<- c(2:5,4,3,NA)
vsetdiff(x,y)
vsetdiff(x,y,multiple=FALSE)
setdiff(x,y) # same as previous line
vsetdiff(y,x) #note the asymmetry

Example output

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

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