0

如何根据出现频率(x 轴)而不是根据术语的字母顺序(y 轴)排列 qplot 中的条形图?

# create a table to store the top 50 most frequent words and plot a barchart
word_freqs = sort(rowSums(tdm), decreasing=TRUE)
top50words <- head(word_freqs, 50)
termFrequency <- rowSums(as.matrix(top50words))
qplot(names(termFrequency), termFrequency, geom="bar", xlab="Terms") + coord_flip()

top50words已经按降序排列术语(从出现次数最多到出现次数最少。但是,在 qplot 中,它是按字母顺序排列的。

4

0 回答 0