[R] find closest match between two vectors
Jannis
bt_jannis at yahoo.de
Thu Dec 16 18:31:45 CET 2010
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?
Cheers
Jannis
More information about the R-help
mailing list