vsetdiff: 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)
Value
A vector of all elements in x which are not in y. If multiple=FALSE is set, only unique values are returned.
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.
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 linevsetdiff(y,x) #note the asymmetry