-3

I'm trying to generate a wordcloud in R with the package wordcloud. That's the easy part, but it seems i'm lacking figuring out how to display the frequency next to the words that appear in the wordcloud. I've been searching everywhere but didn't find anything. Can anyone help me?

The code i'm using is:

wordcloud(Table$words, Table$freq, scale=c(2.5,0.5),m ax.words = 150,
          min.freq = 10, random.order=FALSE, rot.per=0.1, 
          use.r.layout=FALSE, random.color = F, colors=rainbow) 
maccruiskeen
  • 2,748
  • 2
  • 13
  • 23
  • 2
    Can you show what you've tried and provide a reproducible example? – Nancy Dec 15 '15 at 20:28
  • just posted the code i'm using. Can not seem to find any option for adding the frequency in the wordcloud – Dario Francese Dec 15 '15 at 20:47
  • That's a start! Take a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example to get a rundown on what will help you get the best help. – Nancy Dec 15 '15 at 20:55
  • I understand the frustration-- and it does indeed take some work to develop a reproducible question. We can't just write code for you though if we don't have something to base it off of. For example, can you generate a mock-up word cloud with a data set from ```ggplot2``` or another easily-accessed source? Show what you have and what you did, and ideally an attempt to do what you want. That will help us understand what you already know and where you're encountering issues. Chances are you'll figure it out on your own as you work through a simpler example. – Nancy Dec 15 '15 at 21:11

1 Answers1

3

Try something in the veins of this:

library(wordcloud)
words <- c("foo", "bar")
freqs <- c(10, 3)
wordcloud(words = sprintf("%s (%s)", words, freqs), freq = freqs)

?sprintf and ?paste might be helpful.

lukeA
  • 53,097
  • 5
  • 97
  • 100