In our previous blogs the features of both ‘R Visualization’ as an object in your story as well as how to utilize stored output created by Automated Predictive Modelling within SAP Analytics Cloud were discussed.
In this blog the ‘Application Design’ functionality within SAP Analytics Cloud will be shown. More specifically: how R Visualizations might play a role in such an ‘interactive’ Application scenario, both functioning as trigger and result.
By navigating to the Main Menu and via ‘Create – Analytic Application’, a standard template will be generated for your ‘New Analytic Application(1)’:
Within the Analytic Application’s menus, a lot of functionality is similar to what you might find in a generic Story, such as the Insert, Tools and Designer menus and options.
When creating a simple Application, your main working area will be the ‘Canvas’. Just like the objects that will become part of the Canvas, the Canvas itself also has Script possibilities that become visible when you hover over the Canvas-buttom. Some of them you might recognize from Lumira Designer (e.g. OnInitialization).
Even though the final Application will have the following objects:
The first step is creating the ‘result’-objects that will be shown based on the result of a different object (or, possibly as a result of user interaction). In this Application, the user wants to see a Plot (including points and trendline), and, a Table with the Gross Margin and Gross Margin Plan Measures. However; only in case the correlation between these two measures is sufficiently high (e.g. > 0.95) on a Store-level. Where the ‘Plan’ could also be output that was generated in the past by an ‘Automated Predictive Modelling’ Forecast.
The ‘Table’-visualization can be quite straightforward: simply showing the Measures (columns) over Time (rows) in a simple Table Structure. You still might want to tweak a few settings, such as it not being shown at ‘view time’ (i.e. deselect in the ‘Styling’-menu under Actions):
And perhaps hiding it from your overall canvas (i.e. context menu of the Canvas-item):
The plot including points and trendline can be created via a R Visualization using the ‘ggplot2’-library (for an extensive ‘ggplot2’-guide, please check this site).
The R Visualization itself uses the ‘BestRun_Advanced’-dataset, with 2 Measures (Account: Gross Margin, Gross Margin Plan) and 1 Dimension (Store):
While using the ‘ggplot2’-library and ‘ggplot(… aes)) + geom_point() + geom_smooth()’-script in the Editor:
The Preview at the bottom right is an indication that the script is working on the used dataset!
A second R Visualization will calculate what the Correlation is between the Gross Margin and Gross Margin Plan (note: same setup with regards to data, dimensions and measures):
Whereas within the R Visualization’s script:
The ‘onResultChanged’ can be changed. The nice thing about the output of the R Visualization, i.e. the ‘gMCorrelation’-variable storing the result, is that this variable can be called in the script of the object!
Using the below script will show the ‘Table_2’ and ‘RVisualization_1’ Canvas Items if the Correlation is > 0.95:
Please note that it might also be useful to show the ‘nCor’-result on the Canvas, e.g. by converting it using ‘toString()’ and subsequently ‘applyText’ to add it within a Text-item.
On the top-right corner of the Canvas, there is a ‘Run Analytic Application’-button to test the created Application:
When testing the Application, the result is that the two items are shown, as expected (as the preview of the R Visualization showed a Correlation of 0.9875!):
Whereas when the 0.95 is changed to 0.99:
The two visualizations will no longer become visible, and as such only the ‘Correlation Analysis’-header is shown.
As an innovation partner, we want to continue inspiring you. That's why we gladly share our most relevant content, events, webinars, and other valuable updates with you.