如何在 R 中表示像热图和词云这样的术语文档矩阵?

How to represent a term document matrix like heatmap and word cloud in R?

我有一个术语文档矩阵,如下所示。我怎样才能像热图和词云那样表示它?

词云:

library(tm)
library(wordcloud)
data(crude)
crude <- tm_map(crude, removePunctuation)
crude <- tm_map(crude, function(x)removeWords(x,stopwords()))
wordcloud(crude)

对于热图:

library(reshape2)
library(ggplot2)
tdm <- TermDocumentMatrix(crude)
df <- melt(as.matrix(tdm))
df <- df[df$Terms %in% findFreqTerms(tdm, lowfreq = 10), ]
ggplot(df, aes(as.factor(Docs), Terms, fill=log(value))) + geom_tile() + xlab("Docs") + scale_fill_continuous(low="#FEE6CE", high="#E6550D")