P_M <pmart...@broadpark.no> [Sun, Mar 22, 2009 at 06:48:36PM CET]: > > Hi > I have a table with ID (1 to 183) and Location (144 to -22). > My problem is that I want to select the 10 ID's that are closest in Location > to ID 1, ID 2 and so on. > Also, some ID have the same Location. Say, if 11 ID's are closest to ID 100 > I want to randomly choose one of the ID's to select 10 ID's total.
In the general case, the nn function from the RANN package (not part of CRAN but found by rseek) does what you want, but for the one-dimensional case this might be overkill. -- Johannes Hüsing There is something fascinating about science. One gets such wholesale returns of conjecture mailto:johan...@huesing.name from such a trifling investment of fact. http://derwisch.wikidot.com (Mark Twain, "Life on the Mississippi") ______________________________________________ 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.