Skip to Content
Author's profile photo Former Member

SAP Predictive Analysis – Custom R Component cannot find an installed R package?

Some users might have encountered a situation when a R script runs well in the R console or RStudio but throws an error in PA about not being able to find a R package that is already installed to R. For example, the screen shot below was an error I had. It is thrown out by PA custom R component when loading the rgl package

3dplot throws error in PA.PNG

When you get this error, one potential problem could be that the R_LIBS environment variable was not successfully set. In general, R_LIBS need to points to all folders where your R package are installed. Use the .libPaths() function to check where your R libraries are installed

calling libPaths function.PNG

In my machine R packages are installed to two folders as shown above. One potential solution is to append all folders returned by .libPaths() to the system environment variable R_LIBS. Make sure to separate them by semicolon (;). Create R_LIBS if it does not exist.

Assigned Tags

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

      I had the same problem for a while. If you are using the R-studio, it would by default install packages on the first path while PA check the other one.

      Just as a sanity check, you should always check if a folder with the name of the library does exist under the library subfolder in the R-path that is configured on PA.

      You can also explicitly specify the location where you want a package to be installed:

      install.packages("PackName", lib="PATH")