How to see which R packages are installed on an R server using SAP HANA Studio.
In an environment where you are using SAP Predictive Analysis together with SAP HANA integrated with an R Server you might not always have OS access to the R server and can therefore not see which R packages are installed. This impact the use of SAP Predictive Analysis when using SAP HANA Online or “Connect to SAP HANA” connectivity and the built-in R algorithms or custom R algorithms.
If you build a SAP Predictive Analysis Custom R component using SAP HANA Offline or other local files and the required package (algorithm) is installed on the your local R laptop it will normally work. However to get it working using SAP HANA Online the algorithms also needs to be installed on the R server integrated with SAP HANA. In a hosted environment you might not be able to get direct access to the R server to check which algorithms are installed.
Below is a step-by-step description on how to see which packages are installed on the R server integrated with SAP HANA using SAP HANA Studio.
From SAP HANA Studio select the “SQL” to open a SQL console for the SAP HANA system which is connected to the R server.
Type the following script. Replace “DATA” with your own schema.
Execute the script (mark the script and click F8).
The results from running the script. The below result might differ from your depending on the installed packages on your R Server.
If you would like to get more information on the packages installed on the R server these are the additional parameters.
“Package” “LibPath” “Version” “Priority”
“Depends” “Imports” “LinkingTo” “Suggests”
“Enhances” “License” “License_is_FOSS” “License_restricts_use”
“OS_type” “MD5sum” “NeedsCompilation” “Built”
Here is the script if you wish to copy and paste:
SET SCHEMA “DATA”;
DROP TABLE “InstalledPackages”;
CREATE COLUMN TABLE “InstalledPackages”
“Package” VARCHAR(100), “LibPath” VARCHAR(100), “Version” VARCHAR(100), “Depends” VARCHAR(100)
DROP PROCEDURE RSCRIPT;
CREATE PROCEDURE RSCRIPT(OUT result “InstalledPackages”)
LANGUAGE RLANG AS
result <- data.frame(installed.packages())
result1 <- (as.character(result$Package))
result2 <- (as.character(result$LibPath))
result3 <- (as.character(result$Version))
result4 <- (as.character(result$Depends))
result <- data.frame(Package=result1,LibPath=result2, Version=result3, Depends=result4)
CALL RSCRIPT(“InstalledPackages”) WITH OVERVIEW;
SELECT * FROM “InstalledPackages”;
Thanks, this is handy!