我有一个单词列表
a = c("when","to","use","each","effect","","recognizing","each","effect","?",":")
a
[1] "when" "to" "use" "each"
[5] "effect" "" "recognizing" "each"
[9] "effect" "?" ":"
此列表可能包含数千个单词。我怎样才能有效地找出独特的单词,即"当" "至" "使用" "每个" "效果" "识别"
我尽量避免使用for循环。
谢谢
答案 0 :(得分:2)
unique(a)
你可能也喜欢
table(a)
答案 1 :(得分:-1)
您可以使用散列映射来维护列表而不是使用数组。它会自动保持数据的唯一性。