Absolute Wordclouds

I am trying to make several wordclouds to compare terms that are themselves nested within groups. I would like to make one word for each group. A package wordcloudin R may do the wordclouds I need, but each new wordcloud has a size of words scaled with respect to the maximum and minimum frequency of words. This can be set using the parameter scale.

My goal is to make wordclouds where the word size is absolutely related to the frequency of the word, allowing me to visually compare different text words.

library(wordcloud)
dat <- data.frame(word = rep(LETTERS[1:3], 2), freq =  c(10, 5, 3, 20, 10, 6), group = c(1, 1, 1, 2, 2, 2))

dat
#  word freq group
#1    A   10     1
#2    B    5     1
#3    C    3     1
#4    A   20     2
#5    B   10     2
#6    C    6     2

wordcloud(dat$word[dat$group == 1], dat$freq[dat$group == 1]) 
wordcloud(dat$word[dat$group == 2], dat$freq[dat$group == 2]) # Currently the same

Current wordcloud

wordcloud, , MWE ( ). , wordcloud , ( - , ).

?

+4
1

Hm, . , .

anchor <- max(dat$freq)
wordcloud(dat$word[dat$group == 1], dat$freq[dat$group == 1], scale = c(8*max(dat$freq[dat$group == 1])/anchor, 0.5))
wordcloud(dat$word[dat$group == 2], dat$freq[dat$group == 2], scale = c(8*max(dat$freq[dat$group == 2])/anchor, 0.5))
+2

All Articles