find closest match between two vectors
On Dec 16, 2010, at 12:31 PM, Jannis wrote:
Dear list, I hope I can define my problem in an understandable manner. I seek some funktion that finds me the index of the value in a vector 1 that is the least bigger then the value in another vector 2. And this for all values in vector 2. For example: vector 1 : c(1,2,6) vector 2 : c(0,0.5,1,2,3,8) the result should be as long as vector 2 and give the indices of the corresponding elements in vector 1: result: c(1,1,2,3,3,NA) Any suggestions how to do this without doing complicated loops through vector 2?
?findInterval
David Winsemius, MD West Hartford, CT