Please follow steps below to install hana.ml.r.

Step 1: Install SAP HANA Client

Please download and install SAP HANA Client and you will find hana.ml.r_XXX.tar.gz in the install directory.

Step 2: SAP HANA PAL Role Assignment

hana.ml.r contains a set of machine learning algorithms in SAP HANA Predictive Analysis Library (PAL). Please make sure you have installed AFL in your HANA and assign the AFL__SYS_AFL_AFLPAL_EXECUTE and AFL__SYS_AFL_AFLPAL_EXECUTE_WITH_GRANT_OPTION roles.

More details could be refer to SAP HANA PAL.

Step 3: Install Required R Packages

For Windows users, RStudio is recommended and for Linux users, R commend line is used.

The required library are: R6, futile.logger, sets and uuid. Make sure all of the following packages below are installed and libraries loaded.

Installation command, for example, if you want to install R6 package:

Load a library, for example, if you load a R6 package:

Some additional functions you may use for installation:

  1. Clean up the existing hana.ml.r library before the new installation:
remove.packages("hana.ml.r")
  1. Restarting your R session:

Windows: Run “.rs.restartR()” to restart the session on RStudio. Linux: If you have started a new R session then this is already a clean session.

  1. Clean up your existing global variables:
rm(list=ls())
  1. check for installation path:

Step 4: Install Database connectivity package

Specifically, hana.ml.r library supports ODBC or JDBC database connectivity to access the SAP HANA.

1.JDBC

We use ‘RJDBC’ package. First, install ‘RJDBC’ package:

Then, download a jdbc Driver in your local path and we could create a connection as follows: Note that in the direcotry of SAP HANA Client, e.g. ./sap/hdbclient, a jdbc driver ngdbc.jar is provided, you could refer to the path of this driver.

conn.jdbc <- hanaml.ConnectionContext(dsn = <host>:<port>,
                                      username = 'xxxx',
                                      password = 'xxxx',
                                      odbc = FALSE,
                                      jdbcDriverPath = <path to jdbcDriver>,
                                      ...)

2.ODBC

We support ODBC packages ‘odbc’ and ‘RODBC’ and we recommend to use ‘odbc’ as it is faster.

In windows, please use ‘ODBC Data Source Administrator’ to add a new HDBODBC data source to connect to SAP HANA. In Linux, please add ODBC entry of SAP HANA information in your .odbc.ini file.

If you use ‘odbc’ package, create the connection as follows:

conn.odbc <- hanaml.ConnectionContext(dsn = <ODBC data source name>,
                                     username = 'xxxx',
                                     password = 'xxxx',
                                     odbc = TRUE,
                                     ...)

If you use ‘RODBC’ package, create the connection as follows:

conn.rodbc <- hanaml.ConnectionContext(dsn = <ODBC data source name>,
                                       username = 'xxxx',
                                       password = 'xxxx',
                                       odbc = TRUE,
                                       rodbc = TRUE,
                                       ...)

Step 5: Installation of hana.ml.r

Windows: In Rstudio, Run the following command in a console.

Linux: On a R session, run the same command.

install.packages("path to hana.ml.r_XXX.tar.gz", repos=NULL, type="source")

After installation, you could load the library:

> library ('hana.ml.r')