[R] Minimum distance

Douglas Bates bates at stat.wisc.edu
Mon Apr 18 02:20:28 CEST 2005


Williams, Michael wrote:
> G'day, I have a matrix 20000 x 500 populated with all the distances
> between a list of airports and a list of towers. What I'm having trouble
> doing is finding the closest airport to each tower, Any help would be
> greatly appreciated.
> 
> Regards,
> Michael Williams

Sounds like you want to apply the function which.min to the rows of the 
matrix.  See

?apply

and

?which.min




More information about the R-help mailing list