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

KB46077: How to display graphs generated by R Analytics in a Report Services document in MicroStrategy Web?


Community Admin

• Strategy


The article explains how to display graphs generated by R Analytics in a Report Services document in MicroStrategy Web

Users may wish to display a graph generated by R analytics on their Report Services documents. Strategy interacts with R Analytics and both transfer data to each other in order to send input data and to receive the outcome. However, it is currently not possible to receive image data. This technical note describes a way to display an R graphical image on Strategy Report Services documents.
This is best illustrated through the example below.
 
PREMISE:
- Following the instructions in TN: 43665 , the Strategy R Integration Pack has already been installed on the Intelligence Server. 
- The example will use and modify the script from the “R Integration Pack User Guide.”
 
STEPS:
1. Modify the multiple linear regression sample script from the “RIntegrationPackUserGuide.pdf” as follows:
 
#Create data frame for 48 months of data sent from Strategy
df <- data.frame(cbind(target, trend, season))  
 
#Train model(multiple linear regression analysis)
model <- lm(target ~ trend + factor(season),data=df)    
 
#Return predictions
predOutput <- predict(model, newdata = df)
 
#Map the result in matrix to display in a 3D graph
#The data is mapped as 12 months by 4 years
mxoutput <- matrix(predOutput, nrow=12, ncol=4)   
 
#JPEG device driver; specify the folder location       
jpeg("<ServerName>\\Web ASPx\\Images\\SharedFolder\\R graphics\\graphicsByR.jpeg")       
 
#Display the data in perspective plots
#Backgroud color = grey; set plot color and angles
par(bg = "grey");persp(mxoutput, theta = 80,phi = 30, col="aquamarine",shade=0.8)
 
#Close the device driver
dev.off()  
 
2. Open the above script in the deployR utility and set the inputs and outputs as follows:

ka04W000000Oe3JQAS_0EM4400000026KP.jpeg

 
3. Create a stand-alone metric based on the RScript. Replace the last three parameters by the corresponding metrics that will be incorporated in a report.

ka04W000000Oe3JQAS_0EM4400000026KN.jpeg

 
4. Open and edit ‘2 -- Monthly Revenue Forecast’ Report from <Public Objects\Reports\Strategy Platform Capabilities\Strategy Data Mining Services\Linear Regression\Monthly> to add the metric from Step 3.

ka04W000000Oe3JQAS_0EM4400000026KM.jpeg

 
5. Create a blank Report Services document with the above report. Insert an image object specifying the folder path into which R will create an image file based on the metric values.

ka04W000000Oe3JQAS_0EM4400000026Km.jpeg

 
 
6. Execute the document and the R generated graph is displayed in the document as shown below:

ka04W000000Oe3JQAS_0EM4400000026KO.jpeg

 
HOW THIS WORKS:
The folder path and an image name are specified in the following JPEG driver commands, and the device driver captures and saves a graph image until the driver is closed.
 
#JPEG device driver; specify the folder location       
jpeg("<ServerName>\\Web ASPx\\Images\\SharedFolder\\R graphics\\graphicsByR.jpeg")     
 
#Display the data in perspective plots
#Backgroud color = grey; set plot color and angles
par(bg = "grey");persp(mxoutput, theta = 80,phi = 30, col="aquamarine",shade=0.8)
 
#Close the device driver
dev.off() 
 
When a user runs a Report Services document, an individual report execution job for each dataset is executed. The report execution job interacts with R Analytics, and R Analytics will return calculated outputs to the Intelligence Server and generate and save a graph image into the specified folder by the script. The Document Server will pack up all the information including the dataset and the graph image generated by R Analytics in order to finalize the document format.


Comment

0 comments

Details

Knowledge Article

Published:

April 1, 2017

Last Updated:

April 1, 2017