问题
I am able to make word cloud, but my problem is when I take the frequency of word counts, I get words whose frequency is 1. I want words whose frequency is greater than 2. How can I do that?
tdm is just a term matrix. I tried with something like rowSums(m>2)
, but its not working
# define tdm as matrix
m = as.matrix(tdm)
# get word counts in decreasing order
word_freqs = sort(rowSums(m), decreasing=TRUE)
# create a data frame with words and their frequencies
dm = data.frame(word=names(word_freqs), freq=word_freqs)
Trying to make from https://sites.google.com/site/miningtwitter/questions/talking-about/wordclouds/wordcloud1
回答1:
You could simply filter word_freqs
before constructing the data.frame:
word_freqs <- word_freqs[word_freqs > 2]
来源:https://stackoverflow.com/questions/20111432/removing-words-from-word-cloud-in-r