title: How to make the difference between two consecutive elements of a vector and remove the one ending with two zeros if the difference is less than 10
body: <p>I am trying to generate a vector breaks_x which is the result of another vector break_init. If the difference between two successive elements of break_init is less than 10, the element ending with two zeros will be removed.
  My code is always removing breaks_init[i] even if it not ending with two zeros.
  Can anyone help please</p>
  <pre><code>break_init &lt;- c(100,195,200,238,300,326,400,481,500,537,600,607,697,700,800,875,900,908,957)
  breaks_x &lt;- vector()
  for(i in 1:(length(break_init) - 1))
  {
    if (break_init[i+1] - break_init[i] &gt;= 10) {
      breaks_x[i] &lt;- break_init[i]
    } else {
      if (grepl(&quot;[00]$&quot;, as.character(break_init[i])) == TRUE){
        breaks_x[i] &lt;- NA
      } else if (grepl(&quot;[00]$&quot;, as.character(break_init[i])) == FALSE) {
        breaks_x[i+1] &lt;- NA
    } else {
        breaks_x[i] &lt;- break_init[i]
    }
   }
  }
  [1]   0 100  NA 200 238 300 326 400 481 500 537  NA 607  NA 700 800 875  NA 908 957 #result breaks_x
  [1]   0 100 195  NA 238 300 326 400 481 500 537  NA 607 697  NA 800 875  NA 908 957 #what I want my result to be
  </code></pre>