title: Find the indices of last occurrence of the unique elements in a vector
body: <p>I have an unordered vector <code>v</code> like the one shown below and would like to find the indices of the last occurrence of every unique elements in the list.</p>
  
  <pre><code>v &lt;- scan(text="1 2 1 2 1 1 1 3 1 2 2 3 3 3 1 1 1 4 1 1 1 4 1 5 5 6
                  6 2 3 3 4 4 2 2 2 2 2 3 3 3 1 4 4 4 3 2 5 5 5 5")
  v
  # [1] 1 2 1 2 1 1 1 3 1 2 2 3 3 3 1 1 1 4 1 1 1 4 1 5 5 6 6 2 3 3 4 4 2 2 2 2 2 3 3 3 
  # [41] 1 4 4 4 3 2 5 5 5 5
  </code></pre>
  
  <p>Expected result (in order of 1, 2, 3, 4, 5): </p>
  
  <pre><code>41 46 45 44 50
  </code></pre>
  
  <p>I know I can use <code>unique(unlist(v))</code> to find the unique elements but then how to find the indices of their last appearance? Any idea?</p>
  
  <p>Thanks in advance.</p>