vsetdiff {vecsets} | R Documentation |
Find all elements in first argument which are not in second argument.
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
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 |
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
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
[Package vecsets version 1.4 Index]