title: How to retrieve value from a data frame "between" two conditions
body: <p>Can I get value between, for example x-1:x+1, from data frame in R?</p>
  
  <p>if I have data.frame</p>
  
  <pre><code>A &lt;- c(1,2,3,4,5,6,7,8)
  
  B &lt;- c(2,3,4,5,6,7,8,9)
  </code></pre>
  
  <p>and I have <code>x = 2</code>, how to get value that <b>x-1 &lt;= A &lt;= x+1</b>
  so the result is </p>
  
  <pre><code>A B
  1 2
  2 3
  3 4
  </code></pre>