Skip to content
Prev 325561 / 398503 Next

find closest value in a vector based on another vector values

Bert,

thanks... The values should not repeat themselves if the same a is closest to all b, so probably aruns example extended with a unique command works best?

unique(a[sapply(b,function(x) which.min(abs(x-a)))])

thanks,

Andras
--- On Tue, 6/18/13, Bert Gunter <gunter.berton at gene.com> wrote: