Skip to Content
Author's profile photo Louis de Gouveia

From R to Custom PA Component Part 1


SAP has come a long way with their Predictive Analytics solution that has some excellent functionality. Even though the solution has some excellent functionality from time to time you will need to create your own component or code in R.

To create your own component in expert analytics mode can be difficult if you don’t know where to start. There is some good content on SCN like the following links

I however didn’t find a step by step guide that explains it as simple as possible from the beginning to the end. So I’m going to write several blogs that will take you from the beginning to the end of creating your own component. But when I say the beginning, I’m mean start with raw R and understand the syntax up until creating a custom component.

The blog series will cover all these topics.

So this blog being Part 1 we will focus on how we can code in R environment, this environment will help us learn the basic syntax we need to create the R component, will also provide an environment for us to test the R code for our component.


In order to follow these series of blogs you will need to have Predictive Analytics installed. I currently have Predictive Analytics 2.2 installed. I would recommend the same software to follow these blogs.

R Integrated Development Environment (IDE)

There is a few R IDE available in the market. But for this series of blogs I’m going to focus on two products.

  • Option 1 – RGUI, is installed and readily available after the Predictive Analytics 2.2 installation.
  • Option 2 – RStudio, this is a popular R IDE environment that you can download for free.

I would recommend installing both as in my series of blogs I will refer to both environments and at the end of the blogs you will know how to use either one.

R IDE Option 1 – RGUI

You need to ensure that you have installed and configure R as part of your installation.

R Install.png

Once installed you will see on your desktop an icon as shown below. Predictive Analytics from SAP makes use of R and it’s libraries and this is why the application is installed and available after installing Predictive Analytics.


Now from within this environment we can create R code, learn R syntax and get us up to a point where we will have fully functional R code to take into Predictive Analytics for our custom component.

R IDE.png

The small window shows the R console. This console acts like a command prompt but for R. To test everything is in order type in 4+4 as shown in red. The console will then reply with the answer, which is 8.

R Console.png

You will also see that the R has installed in the following directory C:\Users\Public\R-3.1.2

From here you can navigate to the libraries. As we learn R you will find these libraries important, many functions will come from different libraries, some functions will be from libraries not installed yet and we can the install them, each new library installed will make a new folder here.


R IDE Option 2 – RStudio

Before proceeding, I would recommend ensuring that you have installed and configure R as shown in option 1. We will then install the R Studio and make use of the same R libraries. This will allow us to use both environments that will use the same R libraries.

You need to download the RStudio from the below link, you can choose the appropriate version required.

I have selected Windows/Vista/7/8 version as indicated below.


Once you have downloaded, you can install the RStudio. The installation is very simple. Just click next next.

Once installed you can open the RStudio. Will open as shown below. As seen below you will have the R console where you can type in 4+4 and get an answer as shown in Option 1.


By navigating to Tools->Global Options you can see the R install being used, this will also dictate the libraries being used. I’m using the same installation as option 1.


You can see the libraries in the bottom right window under the packages tab. Will show the contents in C:\Users\Public\R-3.1.2\library a discussed in option 1.


Hope you have found this helpful. Part 2 can be found here From R to Custom PA Component Part 2

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ankit Sharma
      Ankit Sharma

      Nice post, thanks! I am catching up on this 🙂