How do I get the barchart in qplot to be arranged according to frequency of occurrence (x-axis) instead of according to the alphabetical order of the term (y-axis)?
# 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 arranges the terms in descending order already (from most number of occurrences to least number of occurrences. However, in qplot, it is arranged according to alphabetical order instead.