on 2022 Jul 07 11:15 AM
I have created a beautiful word cloud in SAC (impressed with myself as total newbie to R). Thank you to the contributors who assisted me in my endeavours.
However, the word cloud consumes a great deal of screen real estate. I can shrink the size of the widget, however, that also reduces the size of the content. Could I please have advice (relevant script) on how I can format the word cloud so that it fills the word cloud container.
I would also like more control over the colours assigned to the words (based on frequency, or proportion, or ranking of the measure). For example:
In addition, is there a limit to the length of words/phrases that can be displayed in a word cloud? I have created another word cloud with phrases. Unfortunately, some of the phrases are being truncated.
I look forward to your good advice. Marea
I've included the code use to create the following word cloud;
#Code to show a wordcloud
library(wordcloud)
library(RColorBrewer)
#Attach the dataset
attach(Opportunities)
#Get Words
Opportunities$'Industry Type'=gsub(paste0('Totals',collapse='|'),"",Opportunities$'Industry Type')
#Opportunities$'Industry Type'=gsub(paste0('Not assigned',collapse='|'),"",Opportunities$'Industry Type')
#Opportunities$'Industry Type'=gsub(paste0('Aust. SME',collapse='|'),"",Opportunities$'Industry Type')
words <-Opportunities$'Industry Type'
#Get Frequency
frequency <-Opportunities$'Count'
#Create the wordcloud
wordcloud(words,frequency, scale=c(5, 1), min.freq=1, max.words=30, random.color=TRUE, random.order=FALSE, rot.per=0.0, colors=brewer.pal(8,"Dark2"))
Request clarification before answering.
Hello Marea,
Try the below code, this will assign color based on frequency. If you want to color on rank, you need to have a rank column in your data frame and change factor to rank instead of frequency.
wordcloud(words,frequency, scale=c(5, 1), min.freq=1, max.words=30, random.order=FALSE, rot.per=0.0, ordered.colors=TRUE, colors=brewer.pal(8,"Dark2")[factor(frequency)])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
60 | |
10 | |
8 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.