Installation.Rmd
Please follow steps below to install hana.ml.r.
Please download and install SAP HANA Client and you will find hana.ml.r_XXX.tar.gz in the install directory.
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.
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:
install.packages("R6")
Load a library, for example, if you load a R6 package:
Some additional functions you may use for installation:
remove.packages("hana.ml.r")
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.
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:
install.packages("RJDBC")
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.
<- hanaml.ConnectionContext(dsn = <host>:<port>,
conn.jdbc 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:
<- hanaml.ConnectionContext(dsn = <ODBC data source name>,
conn.odbc username = 'xxxx',
password = 'xxxx',
odbc = TRUE,
...)
If you use ‘RODBC’ package, create the connection as follows:
<- hanaml.ConnectionContext(dsn = <ODBC data source name>,
conn.rodbc username = 'xxxx',
password = 'xxxx',
odbc = TRUE,
rodbc = TRUE,
...)
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')