Technical Articles
R Visualizations in SAP Analytics Cloud
Author: Geetha Madhuri Bobbili
LinkedIn Profile: https://www.linkedin.com/in/geetha-madhuri-bobbili-971268184/
Introduction:
R is an open-source programming language that includes packages for advanced visualizations, Statistics, Machine Learning and much more.
SAP Analytics Cloud R Visualization feature allows users to integrate their own R environment into SAP Analytics Cloud.
The benefit of this is that people all over the world continue to invest a lot of time and energy into creating new and interesting types of statistical charts and graphs that you can use to analyze and present your data.
Another benefit of integrating R visualizations with SAP Analytics Cloud is that it’s flexible. You can change the chart type, characteristics, and depict your information in a variety of ways.
With this new integration in SAP Analytics Cloud, you can now:
- Insert R-visualizations into your story
- Interact with R-visualizations using SAP Analytics Cloud-controls (such as filters)
- Share these SAP Analytics Cloud stories, which include R-visualizations, with other users.
With the R visualization capability, users can perform statistical and analytical analyses and create truly captivating visuals to reflect these analyses.
Also, it is important to note that these visualizations remain interactive and consider the row-level security of users.
To add R visualizations to a story, you need to have an R server running and connected to SAP Analytics Cloud.
This connection is typically handled by an administrator and includes the server or host address, port number, certificate for encryption, and user credentials.
Prerequisites:
- Before we get started with our visualizations we can check a couple of things. First, make sure you are connected with an R Server.
- To do so your user must have admin rights. Otherwise, please ask your system admin user for help. Different options are available for example you may use your own R Server or use the SAP R Server. To do so go into the main menu and press “Administration” under the point “System”:
- Then proceed to “R Configuration” at the top of the screen. Check if you are connected to the SAP R sever runtime environment or to your remote R connection. If this is the case, we can proceed with our tutorial using the R Visualization in the SAC.
- Second, let’s have a look at our profile setting and make sure the number formatting is set to “1,234.56”. Otherwise, the dataset won’t be recognized correctly in the SAC.
Adding R Visualizations to Stories:
Once you have checked the connection, you can create a story from a data model already on SAP Analytics Cloud.
By choosing insert and R visualization, this allows you to indicate that you want to include a visualization as result from a script from R. It is important to indicate that you only can add visualization, but you can run any kind of R-script once you have validated the required libraries.
Which will generate the following frame on the Canvas. In the ‘Builder’-framework there are two important options:
- Input Data: to import the data into the R Visualization;
- Script: to use the R Script Editor, which applies the R Script on the imported data.
After having imported the data, using the ‘Add Script’-functionality will give the following consoles to work with:
- Editor: R Script should be incorporated here.
- Console: displays what is being executed (either successfully, or else it will display error messages).
- Environment: additional information, such as the name of the imported dataset.
- Preview: preview of the results of the R Script that has been added in the Editor framework.
R Visualizations Hands-On Examples:
Up and Down arrow based on KPI Values:
Word Cloud:
Bubble Chart:
Pie Chart that would display Top 9 and group rest as “Others”:
Correlation Matrix:
Correlation – Scatter Plot:
Diverging Bars:
Ranking – Dot Plot:
Conclusion:
Now we have created R Visualizations in SAP Analytics Cloud.
Thank you for taking the time to read my blog and I hope you find it beneficial. Please like, share and comment 🙂
Stay Safe!
HI Geetha,
Nice Blog. Got a clear picture.
Thank You Madhu...
Regards,
Geetha.
Hi Geetha,
Very Interesting , good job and thanks for sharing such a good blog with R script & Libraries and the underlying Data source !
Regards
Arjun KT
Thank you very much Arjun
Regards,
Geetha.
Hi,
Very good write up. Please write more. Can we create wheel of fortune graph in SAC using R Visualization or Custom widgets?
Thanks and Regards,
Joyal Laj
very nice blog.
Thank you Gurudev 🙂
Hi Geetha,
Very nice blog...
Regards,
Jai
Very nice blog. I want to build a slider or range filter in a story using R script. Could you please help with the code. i am new to R.
Hi Geetha,
great blog thank you. I have a requirement to read some html text from my back end system and present it in the R widget. Which library would you use to present this?
My data looks something like this.
"<p><strong>General comments / YTD:</strong> As every year, <br/><strong>Month:</strong>Growth in all categories."
Kind regards
Alex
HI Geetha,
Thanks for the Organized, clean and neat blog!!
Can we use Predictive analytics and ML algorithms here apart from data visualization ?
thanks
Hi shilpa MukG unfortunately not. These R scripts are for rendering visualisations only, to extend to further chart types that SAC doesn't have in its standard chart engine. Regards, H
Hi Geeta, Can we use Shiny and Party libraries in SAC with the R environment provided?
Hi prashanth pundalik you can retrieve the list of installed R packages in SAC by doing the following
r libs
For sure i can see Shiny in there . Party does get a few hits too as part of other Caret, D3r and data.tree packages.
Regards, H
Hi Geetha Madhuri Bobbili
thanks a lot for this post.
I'm using the up and down arrows from your first example.
I'm strugeling with adding them to a KPI-widget or a table. I can only show them as a stand alone widget.
How did you add them to the KPI?
Thanks a lot
Stefan
Hi Stefan,
I have used canvas page, which allowed me to overlay the objects. I have kept my R Visualization on the KPI widget.
Regards,
Geetha.
Hi Stefan,
I would personally go for tables that can render html and then format your cell values accordingly. This is the most straight-forward approach I could come up with:
This will give you a filled out green up-, or red down triangle depending on the condition. You can now choose any html codes of your liking e.g. HTML Unicode UTF-8 (w3schools.com) or many more. Hope this helps!
Best,
Kevin
EDIT: Sorry, as you can see - even in the post the html got interpreted. The codes used in this case were "▲" and "▼" respectively.
Started Exploring R visualization in SAC and got this blog at very first .
still need some addon knowledge on the same. what are required packages and libraries required to execute the script, plot the graphs etc.
Very nice blog Geetha! Do you a sample of Pareto Chart using R visualization in SAC. Thank you.
Great blog Geetha, thanks for that.
Could you please make the script available here so that we (the beginners) can copy'n'paste it instead of reproducing it?
Thanks.
Tariq
Thank you for your share. Can an R visualization consume a "live" model and an "import" model? Thanks.
Hi Frederic,
generally speaking yes.
There are some limitations to want can be used, see the SAC Help here:
https://help.sap.com/viewer/00f68c2e08b941f081002fd3691d86a7/release/en-US/a948e31a0ff343049bf92f87ee9fd2a5.html?q=R%20visualization
Regards,
Harald
Please share video, if possible, Thanks