Skip to content
Prev 245125 / 398502 Next

find closest match between two vectors

Jannis -
    One approach is as follows:
+   y = vec - x
+   y[y<=0] = NA
+   if(all(is.na(y)))NA else which.min(y)
+ }
[1]  1  1  1  2  3 NA

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Thu, 16 Dec 2010, Jannis wrote: