View source: R/vintersect.R View source: R/Oldvintersect.R
vintersect | R Documentation |
Unlike the base::intersect
function, if the vectors have repeated elements in common, the intersection returns as many of these elements as are in whichever vector has fewer of them.
vintersect(x, y, multiple = TRUE)
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 |
A vector of the elements in the intersection of the two vectors. If multiple=FALSE
is set, only unique values are returned. If the intersection is empty, an empty vector of same type is returned, mimicking base::intersect
.
Carl Witthoft, with some code taken from Sven Hohenstein via Stack Overflow
intersect
, the CRAN package sets
x <- c(1:5,3,3,3,2,NA,NA)
y<- c(2:5,4,3,NA)
vintersect(x,y)
vintersect(x,y,multiple=FALSE)
intersect(x,y) #same as previous line
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.