Re: [R] Selecting closest values

2009-03-22 Thread Frank E Harrell Jr
roject.org [mailto:r-help-boun...@r-project.org] On Behalf Of P_M Sent: Monday, 23 March 2009 1:32 AM To: r-help@r-project.org Subject: [R] Selecting closest values 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

Re: [R] Selecting closest values

2009-03-22 Thread Bill.Venables
g [mailto:r-help-boun...@r-project.org] On Behalf Of P_M Sent: Monday, 23 March 2009 1:32 AM To: r-help@r-project.org Subject: [R] Selecting closest values 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 Loca

Re: [R] Selecting closest values

2009-03-22 Thread Johannes Huesing
P_M [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

Re: [R] Selecting closest values

2009-03-22 Thread jim holtman
If we assume the distance is linear, this might work: > x ID loc 1 1 144 2 2 144 3 3 140 4 4 126 5 5 120 6 6 112 7 7 100 8 8 99 9 9 91 10 11 90 11 12 90 12 13 89 13 15 86 14 16 85 15 17 85 16 18 80 17 19 79 18 20 79 19 21 78 20 22 78 21 23 76 22 24 74 23 25 73

Re: [R] Selecting closest values

2009-03-22 Thread P_M
Yes, of course. ID loc 1 144 2 144 3 140 4 126 5 120 6 112 7 100 8 99 9 91 11 90 12 90 13 89 15 86 16

Re: [R] Selecting closest values

2009-03-22 Thread jim holtman
It would be helpful is you supplied a subset of the data so that we could see what you expect. The 'outer' On Sun, Mar 22, 2009 at 1:48 PM, P_M wrote: > > 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 Locat

[R] Selecting closest values

2009-03-22 Thread P_M
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 I