I have a vector of strings. Check out my vector, it's awesome
:
> awesome
[1] "a" "b" "c" "d" "d" "e" "f" "f"
I'd like to make a new vector that is the same length as awesome
but where, if necessary, the strings have been uniqueified. For example, a valid output of my desired function would be
> awesome.uniqueified
[1] "a" "b" "c" "d.1" "d.2" "e" "f.1" "f.2"
Is there an easy, R-thonic and beautiful way to do this? I should say my list in real life (it's not called awesome
) contains 25000ish mircoarray probeset identifiers.
I'm always nervous when I embark on writing little generic functions (which I'm sure I could do) as I'm sure some R guru has come across this problem in the past, nailed it with some incredible algorithm that doesn't even have to store more than half an element in the vector. I'm just not sure what they might have called it. Probably not uniqueify
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…