return indices of duplicated elements corresponding to the unique elements in R
<p>anyone know if there's a build in function in R that can return indices of duplicated elements corresponding to the unique elements?
For instance I have a vector 
    a &lt;- ["A","B","B","C","C"]
unique(a) will give ["A","B","C"]
duplicated(a) will give [F,F,T,F,T]
is there a build-in function to get a vector of indices for the same length as original vector a, that shows the location a's elements in the unique vecor (which is [1,2,2,3,3] in this example)?</p>

<p>i.e., something like the output variable "ic" in the matlab function "unique". (which is, if we let c = unique(a), then a = c(ic,:)).
<a href="http://www.mathworks.com/help/matlab/ref/unique.html" rel="nofollow">http://www.mathworks.com/help/matlab/ref/unique.html</a></p>

<p>Thank you!</p>