Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R {wordcloud} package, what do the values in scale represent?

Tags:

r

word-cloud

This seems like a simple question, but I can't seem to find an answer anywhere. In the R {wordcloud} package, the wordcloud function, there is a scale value that you can enter. The full documentation (here: https://cran.r-project.org/web/packages/wordcloud/wordcloud.pdf) says: "A vector of length 2 indicating the range of the size of the words."

I can't seem to make any sense of the values though, and I can't find any other documentation. For instance, examples have scale=c(4,.5) or scale=c(8,.3). What do these numbers mean?

I've messed around with different values a bit, but I can't seem to figure out the pattern. Thanks in advance for any help, Seth

like image 445
seth127 Avatar asked Jul 12 '16 17:07

seth127


1 Answers

wordcloud internally calculates

size <- (scale[1] - scale[2]) * normedFreq + scale[2]

where the 2 elements of size are used to set strheight and strwidth. These are graphics values described as follows:

These functions compute the width or height, respectively, of the given strings or mathematical expressions s[i] on the current plotting device in user coordinates, inches or as fraction of the figure width par("fin").

So, long story short, it's height and width.

like image 112
Hack-R Avatar answered Oct 10 '22 20:10

Hack-R