Hi Joh. To echo Bert, more detail would be helpful. But here is a stab at something. Given two numeric vectors, a and b, for each entry of a this finds the index in b of the closest match. It's not efficient at all.
> bestmati <- function( a, b ) { return( sapply( a, function( x ) { which.min( > ( b - x )^2 ) } ) ) } > bestmati( c( 3, 9 ), c( 1, 4, 2, 6, 7, 5 ) ) [1] 2 5 > -- TMK -- 212-460-5430 home 917-656-5351 cell t o p k a t z @ m s n . c o m ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.