[英]How to place words in a word cloud as per its occurrence in R?
I am working on a word cloud using the word cloud package wherein I want the words to appear in the same order as in the sentence/text. 我现在用的词云封装,其中我想的话在同一顺序出现在句子中/文就一个字云工作。 I only know the
random.order
- which plots words in random order. 我只知道
random.order
- 以随机顺序绘制单词。 If false, they will be plotted in decreasing frequency. 如果为假,则将以递减频率绘制它们。 My usage:
我的用法:
comparison.cloud(term.matrix,max.words=300)
commonality.cloud(term.matrix,random.order=FALSE, rot.per=0)
Look at the comparison.cloud function source code (just call it without parens). 查看comparison.cloud函数源代码(只需在没有parens的情况下调用它)。 You will see the following code block somewhere.
您将在某处看到以下代码块。
if (random.order) {
ord <- sample.int(length(words))
}
else {
ord <- order(freq, decreasing = TRUE)
}
You can create your own copy of the function and tinker with how this ord vector is constructed to change the way things are ordered to match your use-case exactly. 您可以创建自己的函数副本,并修改此ord向量的构造方式,以更改订单的方式以完全匹配您的用例。 I would just try removing this block altogether initially and see what happens!
我最初会尝试完全删除这个块,看看会发生什么!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.