问题
I use the wordcloud2
package to render word clouds. It seems that wordcloud2
does not always display the most frequent words.
I said "not always" because the problem is not permanent. It seems that the results are mostly random.
Code :
library(wordcloud2)
library(htmlwidgets)
DataCloud <- as.character(DataTextAnalysis[,1])
DataCloud <- as.data.frame(table(DataCloud))
DataCloud <- DataCloud[order(DataCloud$Freq, decreasing = TRUE),]
DataCloud <- DataCloud[1:10, ]
wordcloud2(data = DataCloud)
Data :
structure(list(`Theme 1` = structure(c(12L, NA, 2L, 4L, 6L, 7L,
NA, 14L, 6L, 6L, 2L, 7L, 5L, 2L, 2L, 2L, 11L, 12L, 2L, 2L, 10L,
NA, 12L, NA, 2L, 13L, 15L, NA, NA, 10L, NA, 1L, 2L, 16L, 6L,
1L, 7L, 9L, 15L, 3L, 1L, 2L, 2L, 2L, 17L, 2L, 17L, 7L, 3L, 2L,
2L, 8L, 6L), .Label = c("Ambiance", "Autonomie", "Changement régulier de hiérarchie",
"Côté familial", "Défi", "Diversité des tâches", "Faire du bon travail",
"Gérer l humain", "Gestion de projets", "Horaires", "Réglage du finisseur",
"Relation client", "Rencontrer de nouvelles équipes", "Responsabilité",
"Technicité", "Travailler avec la hiérachie", "Travailler en binôme"
), class = "factor"), `Theme 2` = structure(c(NA, NA, 13L, 1L,
14L, NA, NA, 4L, 15L, 14L, 10L, 8L, 8L, 5L, 15L, 4L, 13L, 8L,
6L, NA, 3L, NA, 3L, NA, 11L, 5L, 5L, NA, NA, 9L, NA, 16L, 1L,
7L, 8L, 5L, 19L, 2L, 8L, 11L, 5L, 13L, 11L, 11L, 19L, 5L, 19L,
12L, 11L, 8L, 18L, 17L, 4L), .Label = c("Ambiance", "Amélioration",
"Autonomie", "Confiance", "Diversité des tâches", "Être écouté",
"Evolution continue de l entreprise", "Faire du bon travail",
"Hiver", "Liberté", "Matériel performant", "Partager mon savoir-faire",
"Relation client", "Rencontrer de nouvelles équipes", "Responsabilité",
"Solidarité", "Stimulation", "Tranquille", "Travailler dans ma région"
), class = "factor")), .Names = c("Theme 1", "Theme 2"), row.names = c(NA,
-53L), class = "data.frame")
回答1:
Reduce the font size so that all words fit the available page space:
wordcloud2(DataCloud, size = .5)
来源:https://stackoverflow.com/questions/41654007/r-wordcloud2-does-not-always-render-the-most-frequent-words