在 R 中创建词云

Creating a word cloud in R

我正在尝试从大型数据集创建词云。我已经阅读了其中的文字并对其进行了清理。我曾尝试将 wordcloud 与数据帧格式和矩阵格式的数据一起使用,但无论哪种方式我都收到错误消息,指出 TermDocumentMatrix 应用于对象 class 的 UseMethod 中存在错误” data.frame”或“矩阵”。

以下是我尝试以这种身份使用的 dput 的简化版本:

> dput(billing.mat)
structure(c("", "newest", "managers", "are", "doing", "really", "well", 
"responses", "to", "client", "questions", "have", "been", "much", 
"better", "than", "expected", "for", "the", "short", "time", 
"they", "have", "been", "in", "their", "position", "", "trainee", 
"mentioned", "they", "didnt", "feel", "like", "they", "were", 
"getting", "enough", "supporthelp", "with", "the", "specific", 
"things", "their", "team", "does", "the", "team", "puts", "properties"
), .Dim = c(50L, 
1L), .Dimnames = list(NULL, "billing"))
> 

不确定您在做什么,但您可以从这样的矢量创建词云。

library(wordcloud)
library(tm)

data <- structure(c("", "newest", "managers", "are", "doing", "really", "well", 
                    "responses", "to", "client", "questions", "have", "been", "much", 
                    "better", "than", "expected", "for", "the", "short", "time", 
                    "they", "have", "been", "in", "their", "position", "", "trainee", 
                    "mentioned", "they", "didnt", "feel", "like", "they", "were", 
                    "getting", "enough", "supporthelp", "with", "the", "specific", 
                    "things", "their", "team", "does", "the", "team", "puts", "properties"
), .Dim = c(50L, 
            1L), .Dimnames = list(NULL, "billing"))
wordcloud(data)