### Name: match ### Title: Value Matching ### Aliases: match %in% ### Keywords: manip logic ### ** Examples ## The intersection of two sets can be defined via match(): ## Simple version: intersect <- function(x, y) y[match(x, y, nomatch = 0)] intersect # the R function in base, slightly more careful intersect(1:10,7:20) 1:10 %in% c(1,3,5,9) sstr <- c("c","ab","B","bba","c","@","bla","a","Ba","%") sstr[sstr %in% c(letters,LETTERS)] "%w/o%" <- function(x,y) x[!x %in% y] #-- x without y (1:10) %w/o% c(3,7,12)