title: R subsetting vectors using an expression to form indices
body: <p>I came across something which surprized me about subsetting in R.  I have a vector of ascending values, and want to use only those values close to the middle.  So, I just needed something like this:</p>
  
  <pre><code>x &lt;- 1:10
  m &lt;- 5
  x[(m-1):(m+1)]
  </code></pre>
  
  <p>which returns the middle 3 values (that is what I wanted).  But by mistake I used:</p>
  
  <pre><code>x[m-1:m+1]
  </code></pre>
  
  <p>To my surprize, the vector 5, 4, 3, 2, 1 was returned. Could someone please help me understand how R is interpretting this?</p>