Find the most frequently occuring words in a text in R

后端 未结 5 1602
刺人心
刺人心 2020-12-14 13:33

Can someone help me with how to find the most frequently used two and three words in a text using R?

My text is...

text <- c(\"Th         


        
5条回答
  •  醉话见心
    2020-12-14 14:25

    We can split the words and use table to summarize the frequency:

    words <- strsplit(text, "[ ,.\\(\\)\"]")
    sort(table(words, exclude = ""), decreasing = T)
    

提交回复
热议问题