EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB250679: Using the R Integration functionality, how to create a word cloud (wordcloud) image in a specific folder?


Community Admin

• Strategy


This technote explains how to use R to create a word cloud image.

SUMMARY
Starting in Strategy 10, the Data Import functionality let users extract data from Twitter and Facebook. The main part of the SNS data is often textual, and one of the most popular analyses for such unstructured data is to create a word cloud image from it. This technical note provides sample R scripts to achieve that goal and presents some demonstrations.
 
PREMISE

  1. Following the instructions in KB43665, the Strategy R Integration Pack has already been installed on the Intelligence Server.
  2. The R packages “tm”, “SnowballC”, and “wordcloud” are installed in R on the Intelligence Server
  3. A shared folder to which end-users and the Intelligence Server have the access has been created. For the Intelligence Server, it should have a write privilege.

 
CONFIGURATION

  1. Place the attached “Wordcloud.R” in the R Scripts directory of the Intelligence Server. In a Windows environment, it is similar to “C:\Program Files (x86)\R Integration Pack\RScripts”
  2. Open this R script in a text editor and specify the destination folder where a word cloud image should be created. In order to do this, specify the destination folder in line 40. destFolder <- "\\\\SHAREDSERVER\\Public\\"
  3. The text message defined in line 61 will be returned to Strategy from R as an output. When executing an R metric, this metric will display what is written here. The value in line 61 can be changed to any arbitrary text.
ka04W00000148aPQAQ_0EM4400000029Dy.jpeg

Notes:
The attached R script is configured to work in the R Script directory. Therefore, this R script is already executable via an R metric. If a user wishes to place the script in a different directory, specify the folder path through the deployR() interface.
 
FOR END-USERS
In order to create a word cloud image from a metric containing textual data, create a new metric with the following R metric definition but replace the “MetricName” part by the name of the metric you wish to analyze. In other words, the whole definition except the last input metric name is always static.
 


RScript<_RScriptFile="Wordcloud.R", _InputNames="mstrInput">(MetricName)

 
 
DEMO 1: Twitter
As an example, type “Strategy+10” in the Twitter search and populate the data.

ka04W00000148aPQAQ_0EM4400000029Dp.jpeg

 
In a Dashboard, the ID attribute and Text metric may be added to the grid as follows and the data is also filtered by the user language.

ka04W00000148aPQAQ_0EM4400000029E3.jpeg

 
In order to create a word cloud image from the Text metric, create a new metric and use the R metric definition. The last word ‘Text’ refers to the name of the ‘Text’ metric in the Twitter data.
 


RScript<_RScriptFile="Wordcloud.R", _InputNames="mstrInput">(Text)

 

ka04W00000148aPQAQ_0EM4400000029E1.jpeg

 

ka04W00000148aPQAQ_0EM4400000029Dr.jpeg

When the R metric is added to the grid, a word cloud image will then be created in the shared folder. The user can utilize this image for any purposes.

ka04W00000148aPQAQ_0EM4400000029Dh.jpeg

 

ka04W00000148aPQAQ_0EM4400000029Dl.jpeg

 
DEMO 2: Other Metrics
If a user wants to create a word cloud image from attribute elements, s/he first needs to display the elements in a metric, which can be accomplished by using the max function as follows.

ka04W00000148aPQAQ_0EM4400000029Dj.jpeg
ka04W00000148aPQAQ_0EM4400000029Du.jpeg

  
After that, since the metric name is ‘ItemDesc’, specify this name in the same R metric definition.
 


RScript<_RScriptFile="Wordcloud.R", _InputNames="mstrInput">(ItemDesc)

ka04W00000148aPQAQ_0EM4400000029Dw.jpeg

 
 
ERROR HANDLING
Users might come across a machine specific issue in which the execution of the attached R script errors out only when it is kicked by the Strategy R Integration functionality (the same R script works fine in the R console). It appears that loading some R libraries is not successfully done. If such an issue is encountered in a Windows environment, the following files could be used as one possible workaround. In this workaround, the main part of the R script is executed via a batch file. 

  1. Place the attached "Wordcloud" folder directly under the C drive in the Intelligence Server machine.
  2. Modify “wordcloud.bat” under “C:\Wordcloud\Batch\” and rectify the R.exe path if necessary (C:\Program Files\R\R-3.2.0\bin\R.exe)
  3. By default, a word cloud image will be created in the Out folder under “C:\Wordcloud\”. To change the destination folder, open Wordcloud_Batch2.R and revise line 33. destFolder <- "C:\\Wordcloud\\Out\\"
  4. Place Wordcloud_Batch1.R in the R Scripts directory (typically “C:\Program Files (x86)\R Integration Pack\RScripts”). Also, change the message in line 38 if necessary.
  5. End-users should use the following R metric definition for this script. 

 


RScript<_RScriptFile="Wordcloud_Batch1.R", _InputNames="mstrInput">(MetricName)

 
 
Third Party Software Installation:
WARNING:
The third-party product(s) discussed in this technical note is manufactured by vendors independent of Strategy. Strategy makes no warranty, express, implied or otherwise, regarding this product, including its performance or reliability.


Comment

0 comments

Details

Knowledge Article

Published:

May 25, 2017

Last Updated:

May 25, 2017