Hi Bruclee, ?rle may help.
a <- c(5, 10, 13, 19, 23) b <- c(1, 4, 7, 9, 15) ab <- data.frame(value = c(a,b), type=c(rep(0,length(a)),rep(1,length(b)))) ab <- ab[order(ab$value),] ab$v2 <- cumsum(ab$type) ab$matched <- rep(ab$value[ab$type==1],rle(ab$v2)$lengths) (result <- ab[ab$type==0,c("value","matched")]) The code should work. Regards. ----- A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Help-Using-vectorization-method-for-vectors-comparision-tp3004952p3005012.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.