title: R - Getting rid of duplicate elements in vector
body: <p>I'm trying to remove duplicate elements from any integer vector but without built-in functions: <code>duplicated()</code>,<code>unique()</code> and <code>anyDuplicated()</code>. Result however must be the same as result of <code>unique()</code>.</p>
  
  <p>So far I managed to get values from vector in increasing order (which is not good enough). I did as follows (for given vector):</p>
  
  <p><code>vec &lt;- c(1,2,2,4,1,1,5,6,3,9,0,4)</code></p>
  
  <p>I can use <code>vec &lt;- sort(vec)</code> and then <code>rle(vec)$val</code> to get vector of values in increasing order. I also managed to get ordering vector from sorting function by <code>sort(vec,index.return=TRUE)$ix</code> and using that I'd like to apply this ordering to <code>result</code> vector (however it is not possible since <code>result</code> is shorter then <code>vec</code>).</p>
  
  <p>Any ideas how to solve this problem? Thanks in advance</p>