I've created a wordcloud in SAC using an imported dataset - it's fabulous, just what the client is looking for. However, when I create a wordcloud over a live data connection the wordcloud includes a total. There doesn't seem to be an option in the widget functionality to remove the totals. I'm assuming the answer lies in the Rscripting. I've included the basic code fyi and the wordcloud.
#Code to show a wordcloud
library(wordcloud)
library(RColorBrewer)
#Attach the dataset
attach(Opportunities)
#Get Words
words <-Opportunities$'Industry Type'
#Get Frequency
frequency <-Opportunities$'Count'
#Create the wordcloud
wordcloud(words,frequency, scale=c(10, 1), min.freq=1, max.words=30, random.order=TRUE, rot.per=0.35, colors=brewer.pal(8,"Dark2"))

Request clarification before answering.
Marea,
Try changing the min.freq to >1 instead =1. Totals wont be coming more than once in your data frame. Alternatively you can strip of the word "Totals" explicitly from the data frame itself before using it in word cloud. Put this before you get #words. Please match your column name as per your data frame.
Opportunities$IndustryType=gsub(paste0(Totals,collapse='|'),"",Opportunities$IndustryType)Regards
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Marea,
Glad it worked for you. For wider audience if they want to remove more than one word, they can be captured in a data frame and passed on to remove operation. Something like below.
word_to_remove=c("NA","Not assigned","GrandTotals","Subtotals","Totals") // Add your words
Opportunities$IndustryType=gsub(paste0(word_to_remove,collapse='|'),"",Opportunities$IndustryType)Regards
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi marea.england2,
filter your input data like this:
In the builder panel click on the grey(!) area to open the input data panel.

Add a filter for e.g. Industry Type dimension.

Toggle switch to exclude selected members and select e.g. "Totals".

Would be interested if this works for your case as well.
Kind regards
Christoph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Christoph. Again thanks for your response. The challenge I have is that Totals was not part of the available dataset (therefore I couldn't filter it as shown above). Totals were being calculated (in the same way that you may display totals for table). Unfortunately I couldn't "Hide Totals" for the widget.
Thank you again for sharing your valuable time, skill and experience.
Kind regards
Marea
Hi marea.england2,
try
words <- subset (words, select = -Totals)If you don't succeed, please share the structure of your data frame "words".
Kind regards
Christoph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christoph Thanks for your response.
I used the code identified above in my question The example I copied from didn't reference a data frame. Can you recommend examples for wordcloud which use a dataframe.
I wasn't sure where to place the code snippet you advised.
The word Totals is not included in the dataset. The script appears to be calculating a total. I'm wondering if a setting in the query Opportunities results in a total on Industry Type? Your thoughts.
Again your response and time is much appreciated. Kind regards Marea
Hi marea.england2,
"words" might not be a data frame, but "Opportunities". Like nikhil_1486 mentioned, remove "Totals" from there before you assign it to "words". You should not see the value "Totals" in the vector "words" after assignment.
Maybe share the "Environment" area of the script editor in SAC (upper right area). There the data frames and vectors should be listed with values.
Kind regards
Christoph
Hi Christoph Thank you again. Unfortunately, I wasn't able achieve the desired result with the code suggestions. The outcome may have been more successful if my understanding or R was more effective. Thank you again for your time. Very much appreciated.
Fortunately, Nikhil was able to provide a workable solution.
Kind regards
Marea
marea.england2
and the option through exceptions in the filters in the input date section is not suitable?You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aleksey thanks for your prompt. I don't quite know what you mean by filters in the input date section means. I'll try the options suggested by Nikhil and Christoph and advise. I'm newish to SAC and even newer to rscripting. I seem to be able to get myself started, but not quite exactly where I need to. I do truly appreciate your response.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.