title: How to get a value from a particular row from the last using r
body: <p>I want to get a value from a particular row from the last. I have tried this so far and used tail function to get last two values</p>
  
  <pre><code>&gt; x &lt;- sample(1:40, 10, replace=F)
  &gt; x
   [1] 17 35 18  4 12 23 36 29 22 16
  &gt; y&lt;-tail(x,2)
  &gt; y
  [1] 22 16
  </code></pre>
  
  <p>Using the tail function we get last two values 22 and 16 But I only want first value that is 22. I know it has an easy solution but i am not able to find it. </p>