r - Choosing entries that are approximately x-apart -
I have a vector whose entries show the location on the sequence, the distance between entries on the sequence is 1 to 10 ^ 7 Is between For a given X I have to get a pair of entries about one distance.
Example:
v = [1 2 3 1000 1002 2000]
After that for X = 1, we [1,2], [1, 3], [2,3], [1000,1002] and X = 1000, we can get [1,1000], [2, 1000], [1002,2000] etc.
Any ideas of doing this? Thank you. Perhaps such a function will work:
dist = (witch, Margin) {d = extension. Grid (VCC, VCE [2: Length (VCC)] D $ diff = abs (abdomen (D $ Var1 - d $ Var2) - Margin) D [Order: Running D: v = c (1, 2, 3, 1000, 1002, 2000) dist (v, 1000) output will be:
Var1 Var2 diff 5 1002 2 0 18 2000 1000 0 20 2 1002 0 28 1000 2000 0 11 1002 3 1. .. A data frame with all pairs sorted in the order of difference. / P>
Comments
Post a Comment