How to make a unique set of names from a vector of strings?

前端 未结 1 779
失恋的感觉
失恋的感觉 2020-12-11 14:59

I have a vector of strings. Check out my vector, it\'s awesome:

> awesome
[1] \"a\" \"b\" \"c\" \"d\" \"d\" \"e\" \"f\" \"f\"
相关标签:
1条回答
  • 2020-12-11 15:25

    Try make.unique() where the very first example of the help page is already spot-on:

    make.unique(c("a", "a", "a"))
    [1] "a"   "a.1"   "a.2"
    

    The help page lists Thomas Minka as author. Buy him a beer one day :)

    0 讨论(0)
提交回复
热议问题