Skip to content
Prev 206558 / 398503 Next

enty-wise closest element

On Jan 17, 2010, at 11:00 AM, Andreas Wittmann wrote:

            
You are failing to use the indices that which.min is providing. (And I  
think the closest in ind1 to ind2[1] is not 1, but rather 4, so see if  
this looks more responsive to your expectations:

 > for (i in length(ind2):1)
+ {
+ print( ind1[which.min(abs(ind1-ind2[i]))] )
+ }
[1] 10
[1] 4
[1] 4
David Winsemius, MD
Heritage Laboratories
West Hartford, CT