wordcloud2 drops long words, which gets the colors mismatched

139 views Asked by At

so i have a dynamic list of text that i want to visualize in a wordcloud. sometimes some of the words are too long and they get dropped from the display. i can scale down the size of everything, but it's not always clear what scale i should get down to in order to prevent things from being dropped. i'd rather not fiddle with this and just accept some things are dropped. also, everything is in a shiny app and i have a slider to control scale if really needed. the problem though is i want my text colored by properties of the words in my dataset. in this example below you can see how each "word" has a color associated with it...

wc <- data.frame(
    word = c("too big to fit this one is","red","green","blue"),
    freq = c(2,1,2,3),
    col = c("black","red","green","blue"),
    stringsAsFactors = FALSE
)

>wc
                        word freq   col
1 too big to fit this one is    2 black
2                        red    1   red
3                      green    2 green
4                       blue    3  blue


wordcloud2(wc, color = wc$col)

this then draws the wordcloud but the first element is dropped and the colors don't drop too ("red" is colored black, "green" is colored red, and "blue" is colored green). i can't do wordcloud2(wc, color = col) like an aes style call in ggplot, the wordcloud does draw but all the text is clear... i can hover over it but not see any of it. anyone else work through this issue? thanks!!!

0

There are 0 answers