简体   繁体   English

如何在R中出现单词云中的单词?

[英]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.

相关问题 如何为第二次及以后出现的单词赋予单词R - How to gsub a word for its second and later occurrence R 创建短语的“单词”云,而不是R中的单个单词 - Creating “word” cloud of phrases, not individual words in R 从R中的词云中删除特定词 - Removing specific words from word cloud in R R中具有多个单词和特殊字符的词云 - Word cloud in R with multiple words and special characters 如何获取 R 中的单词列表并计算每个单词的字符数并将计数频率存储在数组中? - How do I take a list of words in R and count the number of characters per word and store the frequency of counts in an array? 如何用R替换来自特定单词且首字母大写的单词 - How to replace words that come a specific word and has its first letter in upper case with R 使用R编程创建的词云中包含不必要的词 - Unnecessary words included in the Word cloud created using R programming 如何计算R语言中字符串中每个单词的出现次数 - how to count number of occurrence of each words in a string in r language 我如何在 R 中随机选择一个句子并计算每个单词的字符数并根据单词中的这些数字对文本进行排序 - How do I take a random of sentence in R and count the number of characters per word and sorts the text according to those numbers from words 如何提取R中单词子集的单词频率? - how to extract word frequency for a subset of words in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM