R 中 WordCloud2 的 max.word 参数的等效项

oww*_*w14 2 r word-cloud

我正在尝试使用Wordcloud2in构建一个词云R,以便利用 Shiny。我必须做的一件非常重要的事情是保持在词云中表示的固定最大单词数(例如 150)。因此,无论可用的单词数量有多少,我只想在云中可视化最多 150 个单词。在 中Wordcloud,该参数max.words=可用。但是,我无法找到Wordcloud2允许我添加此参数的等效内容。我对此做了很多研究,但似乎找不到它。我的代码Wordcloud2非常简单

mr = table(data, header=TRUE)
wordcloud2(mr, color = ifelse(mr[, 3] > 0, 'green', 'red'), fontWeight = "bold")
Run Code Online (Sandbox Code Playgroud)

我是否可以添加任何参数(例如max.words=(在 中可用Wordcloud))以保证我的云中不再出现 X 个单词?

我的数据是3列,例如:

              WORD VALUE SENT
1         topnotch     1    1
2             good     2    1
3             nice     11    0
4         inspired     14    0
5        beautiful     21    0
Run Code Online (Sandbox Code Playgroud)

Zac*_*ach 5

我不认为你可以通过任何论据来实现这一目标。我只是在将数据集传递到词云之前对数据集进行子集化,例如:

data <- data[order(data$Value, decreasing = TRUE), ]
pass_to_wordcloud <- data[1:150, ] #or set 150 to whatever
Run Code Online (Sandbox Code Playgroud)