Using JRI to call R functions from Java
The JRI allows you to execute R commands inside Java applications as a single thread. JRI loads R libraries into Java and thus provides a Java API to R functions.
Make sure all the steps in the earlier recipe Using Java objects in R are completed.
How to do it...
To use JRI to call R functions from Java, follow these steps:
- Set up environment variables
R_HOMEto where R has been installed and add the R
bindirectory to the environment variable
- Open a new terminal window (on OS X and Linux systems) or open a command prompt window on Windows. Make sure to change the values according to your environment. The following commands help to set up environment variables on OS X and Linux systems. Make ...