Using R Visualizations in SAP Analytics Cloud

16 mei 2018

Besides being a programming language with a huge number of libraries containing statistical techniques, it can (and should!) also be used for its graphical libraries (e.g. ggplot2).

Recently, it became possible to integrate a user’s ‘R Environment’ with regards to these graphical libraries into a SAP Analytics Cloud story by using the ‘SAP Analytics Could R Visualization’-feature.  

To visualize this new feature, a simple example will be used: a dataset with 40 months (01.2015 till 04.2018) of Sales/Revenue data in combination with 8 months of calculated forecast (05.2018 till 12.2018) is used.

Having created a new basic Model with the above-mentioned 48 months of data:

We can now add the R Visualization within our Canvas page of a new Story:

Which will generate the following frame on the Canvas:

In the ‘Builder’-framework you see 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:

Where:

  • 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.

When starting to add R Script in the Editor, there is an auto-complete wizard, just like in the R Studio for example:

Please note that in general you will of course start with the library( …) statements, to initialize the R Script packages that are installed by default. But, it is also possible to just use simple statements, such as ‘plot(…)’:

Whereas changing the ‘x = dataset2’-statement to ‘x = dataset2$MontQ’ would result in the following error:

…As the ‘MontQ’-dimension of course not exists in the dataset2-model.

Adding some additional lines of code (e.g. lines, color and title):

Where executing will result in the following R Visualization:

Which is of course not the prettiest Visualization, but, surprise me yourself with something exciting! 

McCoy's consultants are specialized in Predictive Analytics and are more than willing to help you on the road of Predictive Analytics. Please feel free to contact us for more information!