title: find similar elements in a matrix line in R
body: <p>I have a matrix of which 1 row looks like</p>
  
  <pre><code>  [1] 3.630380e-04 2.508100e-04 2.397480e-04 3.583060e-04 1.352502e-03
    [6] 3.615660e-04 1.070212e-04 1.851614e-03 4.862520e-04 3.133680e-05
   [11] 1.509084e-03 1.971120e-04 9.395720e-05 2.467100e-03 3.695440e-05
   [16] 4.840520e-04 9.587220e-05 3.482520e-03 2.580140e-04 4.161880e-03
   [21] 1.826980e-04 3.016000e-03 3.177400e-03 1.281218e-04 8.437420e-04
   [26] 1.823138e-03 9.580200e-04 9.907120e-04 2.582140e-03 2.205160e-04
   [31] 6.575000e-05 1.875756e-03 3.671640e-04 2.528060e-05 4.163980e-04
   [36] 7.939280e-04 2.894380e-04 2.474960e-04 2.101340e-04 2.241000e-03
   [41] 1.254614e-04 5.975560e-04 7.159760e-05 3.125960e-04 1.311358e-03
   [46] 4.742180e-04 7.947780e-07 2.819960e-04 5.153660e-04 4.901420e-04
   [51] 2.108020e-03 1.122480e-03 6.398160e-04 8.454800e-04 3.870840e-05
   [56] 4.835640e-04 1.311954e-03 6.320340e-06 3.058540e-03 5.186800e-04
  </code></pre>
  
  <p>I would like to start in column i (where i would be column 29 for this specific row) and go to the right and the left and detect for how many columns the value stays within 10e-4 of the value of column 29. So I don't want to round any of the numbers but to just evaluate the difference. If the tolerance is kept between col 29 and col 30 and col 29 and col 28 then the algorithm shoudl proceed to check from col 29 to col 27 and col 29 to col 31.</p>
  
  <p>Thanks </p>