Sasak
Sasak

Reputation: 199

Scale in word cloud

I have this dataframe

df <- structure(list(word = structure(c(1L, 12L, 23L, 34L, 43L, 44L, 
45L, 46L, 47L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 24L, 25L, 26L, 27L, 
28L, 29L, 30L, 31L, 32L, 33L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 
42L), .Label = c("word1", "word10", "word11", "word12", "word13", 
"word14", "word15", "word16", "word17", "word18", "word19", "word2", 
"word20", "word21", "word22", "word23", "word24", "word25", "word26", 
"word27", "word28", "word29", "word3", "word30", "word31", "word32", 
"word33", "word34", "word35", "word36", "word37", "word38", "word39", 
"word4", "word40", "word41", "word42", "word43", "word44", "word45", 
"word46", "word47", "word5", "word6", "word7", "word8", "word9"
), class = "factor"), frq = c(1975L, 1665L, 1655L, 1469L, 1464L, 
1451L, 1353L, 1309L, 1590L, 1545L, 1557L, 1556L, 1130L, 1153L, 
1151L, 1150L, 1144L, 1141L, 1115L, 194L, 195L, 135L, 135L, 130L, 
163L, 167L, 164L, 159L, 153L, 145L, 143L, 133L, 133L, 153L, 153L, 
150L, 119L, 115L, 115L, 115L, 114L, 113L, 113L, 113L, 115L, 102L, 
101L)), .Names = c("word", "frq"), class = "data.frame", row.names = c(NA, 
-47L))

And I would like to create a word cloud based on the frequency.

In order to make this word cloud I use this lines of code:

library(wordcloud2)
wordcloud2(df, color = "random-light", backgroundColor = "green")

However an issue I face is that the word cloud doesn't have all the words. When I refer all words I mean these words with the lowest frequency.

Is there any scale in order to have all words in word cloud and the most frequency word be a little smaller in order to see all words?

As I can understand this happens because the highest frequencies have big difference with the others in the list

Upvotes: 1

Views: 1479

Answers (1)

user6473579
user6473579

Reputation:

You should directly rescale your frequencies. You could for example do :

p_scaled = p^(1/n) with n sufficiently big so that even the words with the lowest frequencies would appear on the word cloud.

Upvotes: 1

Related Questions