title: R shortcut to getting last n entries in a vector
body: <p>This may be redundant but I could not find a similar question on SO. </p>
  
  <p>Is there a shortcut to getting the last <em>n</em> elements/entries in a vector or array <em>without using the length</em> of the vector in the calculation?</p>
  
  <p><code>foo &lt;- 1:23</code></p>
  
  <pre><code>&gt; foo
   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  </code></pre>
  
  <p>Let say one wants the last 7 entities, I want to avoid this cumbersome syntax:</p>
  
  <pre><code>&gt; foo[(length(foo)-6):length(foo)]
  [1] 17 18 19 20 21 22 23
  </code></pre>
  
  <p>Python has <code>foo[-7:]</code>. Is there something similar in R? Thanks!</p>