Identification of unique terms from a list of character vectors

I have a list of character vectors in R representing sets of matching words. From this, I would like to extract a character vector that captures all the words that appear in the list of character vectors. I think that I know how to effectively move from the symbolic vector of words to the unique symbolic vector of words that have appeared. What I do not know how to do is to effectively collapse the list of character vectors into one character vector. Any advice on how to properly approach this or a common problem would be greatly appreciated!

+4
source share
1 answer

Use unlist() :

 > x <- list(l1=c("a","b","c"), l2=c("b","d")) > unlist(x) l11 l12 l13 l21 l22 "a" "b" "c" "b" "d" 

And to get unique values, just use unique :

 > unique(unlist(x)) [1] "a" "b" "c" "d" 
+10
source

Source: https://habr.com/ru/post/1300670/


All Articles