Search code examples
runiquewords

How to find unique words given a list of words in R


I have a list of words

a = c("when","to","use","each","effect","","recognizing","each","effect","?",":")
a
[1] "when"        "to"          "use"         "each"       
[5] "effect"      ""            "recognizing" "each"       
[9] "effect"      "?"           ":" 

This list could have contained thousands of words. How can I effectively find out the unique words, i.e. "when" "to" "use" "each" "effect" "recognizing"?

I am trying to avoid for loops whenever possible.

Thanks


Solution

  • unique(a)
    

    You might also like

    table(a)