Getting started with R in SAP Analytics Cloud

After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Explain R visualizations and the integration with SAP Analytics Cloud
  • Access R in an SAP Analytics Cloud
  • Use the R script editor

R visualization overview

R language

The R language is widely used among statisticians and data miners for developing statistical software and data analysis and can be integrated with SAP Analytics Cloud (SAC) to create R visualizations.

R visualization is the very powerful feature of SAP Analytics Cloud where we can use R code to create more complex charts that are not directly available in SAP Analytics Cloud.

A series of visualizations created using R code. They are various charts such as heat maps and word clouds

R integration with SAP Analytics Cloud

R code integration

A 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 the R visualization capability, you can perform statistical and analytical analyses and create truly captivating visuals to reflect these analyses.

Once integrated, it can be used in SAP Analytics Cloud to:

  • perform statistical analysis using a variety of techniques such as linear and non-linear modeling, time series analysis, and clustering
  • expand the visualization capability of SAP Analytics Cloud to tell even richer stories.

Using R in SAP Analytics Cloud, you can do the following:

  • Insert R visualizations into your stories
  • Interact with your visualizations, using controls such as filters
  • Edit your R scripts and preview visualizations
You can not only add visualizations, but you can run any kind of R script when you have validated the required libraries. Therefore, you could run a cluster model in R and then add the output as a visualization into your SAP Analytics Cloud story.

Access R in SAP Analytics Cloud

Accessing R in SAP Cloud

To add R visualizations to a story, you need to have an R server running and connected to SAP Analytics Cloud. Your system must be configured to connect to an R runtime environment.

Depending on your region, you may either have:

  1. An R server that you set up with an R engine running on a machine in the cloud and configured to SAP Analytics Cloud
  2. An R server runtime environment provided by SAP

This connection is typically handled by an administrator and includes the server or host address, port number, certificate for encryption, and user credentials.

If you do not have an R server connected to SAP Analytics Cloud, please first visit Using R with SAP Analytics Cloud: Best practices for connecting and running your R environment

Access R in an SAP Analytics Cloud story

Add R visualizations from the story menu

Inserting an R visualization in a your story is easy! You can either use the Add or Moremenu options. The interaction below will test your knowledge of inserting elements into stories.

R packages

R packages

There are a number of packages that you can use, but the ggplot2 package is popular and worth exploring as a starting point.

Depending on the package you choose, you can create different types of plot, for example:

  • Static outputs when using ggplot2 or lattice
  • Interactive outputs when using plotly, highcharter, networkD3, or DT

For a list of packages available, see

  • In the R environment managed by SAP, the Shiny R package isn’t supported due to public network access security considerations.
  • Please remember that SAP Analytics Cloud hosts an R runtime environment with R packages that can be called using R scripts. R packages are NOT provided under SAP’s license terms and conditions: each is governed by an open source license assigned by the package’s copyright owner.

R script editor

The SAP Analytics Cloud R script editor is similar to that used in RStudio.

The R script editor is a 4 screen panel that allows you to paste and execute your R code, monitor warnings and error messages, view data information, and a preview of your visualization.

R script editor

In the interaction below, learn move about the editor, console, environment and preview panels of the R script editor in SAP Analytics Cloud.

Use suggested code in the R script editor

A list of suggested code is displayed if you press Ctrl + + + Space , or if there are multiple suggestions based on the characters you have typed in the R script editor.

Based on your coding context, the available R functions, data frames, R packages, vectors, arguments, input parameters, and function lists appear on the left with a corresponding description (if available) on the right.

The R script editor with the suggested code list (left) with a corresponding description (if available) on the right.

To reference a data frame, enter the three letters of the data frame name.

  • You can use the up, down, PgUp, PgDn, Home, and End keys to navigate the displayed list of suggestions. Select a suggestion to insert it into your script.
  • If you combine a data frame name with $, a list of the column names for the data frame is displayed.

R code snippets

Code snippets and examples

Sample scripts to render R-based visualizations are provided for your convenience. The code and visualizations rendered by these samples are for instructional purposes, but you can use these samples to generate visualizations based on your data.

R script editor with the code snippets and examples showing in the dropdown menu using the path below.

Navigate to <>, choose Snippets and choose Examples to access the samples.

Examples of R visualizations and the associated R code

By choosing insert and R visualization, you can create a wide variety of charts using a script from R. Here are a few examples of R visualizations and the associated R code from the R code script editor:

Bubble Chart

Bubble chart on the top with the associated code in the R code editor on the bottom

Diverging bars

Diverging bar chart on the left with the associated code in the R code editor on the right.


Scatterplot on the left with the associated code in the R code editor on the right.

Up and down arrows based on KPI

KPIs with up and down arrows on the top with the associated R code script editor on the bottom.

Word Clouds

A word cloud on the top and the R code editor script below.

Save progress to your learning plan by logging in or creating an account

Login or Register