Install R Extension for RapidMiner on Ubuntu Linux or OSX

Update: Instructions provided by RM with R Extension are now working quite nicely; while html files are available within the package (RapidMiner R Extension Extension/resources/com/rapidminer/resources/help); they do not appear to be available online; I am providing them (w/ minor modifications) here for reference purposes.

  1. Installation Guide (Linux, OSX, Windows)
    1. All
  2. Using the console
  3. Using R Operators
  4. Acknowledgments

1. Installation Guide for Linux

For using the R Extension of RapidMiner, you need to have R installed on your computer (http://www.r-project.org/). You will need an R version of at least 2.12.

    1. Install R (e.g. sudo apt-get install r-base r-base-dev for Ubuntu)

 

    1. Set the required environment variables and prepare the environment for R. Open a bash terminal and follow the below stepsexecute “sudo su”
        1. Set the environment variable JAVA_HOME to the Java installation directory (e.g. /usr/local/jdk1.6.0_37/) and not the bin directory. You could type the below command in the terminal to set JAVA_HOME in ubuntu
          • JAVA_PATH=$(which javac);if [ $JAVA_PATH = /usr/bin/javac ];then export JAVA_HOME=$(readlink -f /usr/bin/javac | sed “s:bin/javac::”) ;else export JAVA_HOME=$(echo $JAVA_PATH | sed “s:bin/javac::”);fi; export JAVA=${JAVA_HOME}bin/java;
        1. Configure the java installation that will be used with R, by running the below command ,
          • ” R CMD javareconf ” as superuser (use “sudo su” in Ubuntu to login as super user. Just “sudo <<cmd>>” does not work)
        1. Open the R console (just type “R” in terminal) and install the packages rJava and JavaGD by typing the following commands. These packages are required for accessing R from Java.
          • install.packages(c(“rJava”,”JavaGD”))

          Check the log messages displayed in the console to ensure that, the packages are installed successfully.

        1. Exit the super user session
        1. Add the below lines to the top of the files <<rapidminer_dir>>/scripts/RapidMinerGUI and <<rapidminer_dir>>/scripts/rapidminer to make sure that the appropriate environment variables are set before launching RapidMiner. The top of the files should look like shown below#!/bin/sh

          JAVA_PATH=$(which javac);if [ $JAVA_PATH = /usr/bin/javac ];then export JAVA_HOME=$(readlink -f /usr/bin/javac | sed “s:bin/javac::”) ;else export JAVA_HOME=$(echo $JAVA_PATH | sed “s:bin/javac::”);fi; export JAVA=${JAVA_HOME}bin/java;

          export R_HOME=`find \`whereis R | sed s/R://\` -name libR.so | sed -r ‘s/(.*)\/.+\/libR.so/\1/g’`

          export PATH=`find \`whereis R | sed s/R://\` -name libR.so | sed -r ‘s/(.*)\/libR.so/\1/g’`:$PATH

 

    1. Launch RapidMiner in the terminal, by running the launch script in the rapidminer folder. (e.g <<rapidminer_dir>>/scripts/RapidMinerGUI)
      if the script is not executable, please mark it as an executable using the command
      chmod +x <<rapidminer_dir>>/scripts/RapidMinerGUI

 

    1. Configure the jri Library path in the RapidMiner. Open RapidMiner and configure the Jri library path in R extension assistant.You could use the below command to find the jri Library path
      • find `echo “.libPaths()” | R –slave | sed s/’\[[0-9]*\]’// | sed ‘s/”//g’` -name *jri.so

 

    1. If you have selected the file, RapidMiner will exit, since the new environment variables are still unknown and you need to restart the program manually. If you have started RapidMiner from console or another program, please restart the console or the program as well.

 

1. Installation Guide for Mac OS X 10.8+

For using the R Extension of RapidMiner, you need to have R installed on your computer (http://www.r-project.org/).

  1. After you have installed a proper version of R, you need to install rJava and JavaGD available on CRAN by typing the following command on the R console:
    install.packages(c("rJava","JavaGD"))
    Then you should activate rJava and JavaGD in the R package management.
  2. Add following lines to your ~/.bash_profile or ~/.profile:
    export R_HOME=/Library/Frameworks/R.framework/Resources
    export JAVA_HOME=$(/usr/libexec/java_home)
  3. Now you can configure RapidMiner. Click on Select JRI library file and select the JRI dynamic-link library (e.g. /Library/Frameworks/R.framework/Resources/library/rJava/jri/libjri.jnilib).
  4. After selecting the file you have to restart RapidMiner and the console you have started RapidMiner with.

 

1. Installation Guide for Windows

For using the R Extension of RapidMiner, you need to have R installed on your computer (http://www.r-project.org/). You will need a R version of at least 2.12. Please make sure that R is compiled for the same architecture as RapidMiner: An 32 bit RapidMiner can only access a 32 bit R, and a 64 bit RapidMiner needs 64 bit R.

  1. After you have installed a proper version of R, you need to open the R console to prepare R to support being accessed by RapidMiner. You have to install rJava available on CRAN by typing the following command on the R console:
    install.packages("rJava")
  2. You should now type .libPaths() and note the listed directories. One of them is used to store the rJava package and you will need to remember it when RapidMiner starts. If finished successfully, R is prepared for RapidMiner.
  3. If you don’t already have a valid R_HOME environment variable pointing to the installation directory of R, you need to create it. Be careful that this points to the actual used R directory, so that the architecture matches. Don’t point to the bin folder, just the install folder (e.g. C:\Program Files\R\R-2.15.0).
  4. Now you have to make sure, that RapidMiner can find the program libraries of R by adding it to the PATH environment variable of your operating system: Add <R_HOME>\bin\<architecture> to your PATH environment variable (e.g. C:\Program Files\R\R-2.15.0\bin\x64 for 64 bit RapidMiner and R). The architecture depends on the architecture of RapidMiner. If you want to execute 32bit RapidMiner, you must set the path to the i386 subdirectory, otherwise choose thex64 subdirectory. This directory must contain the dynamic link library of R, which is called R.dll, and all dependent libraries. Make sure that you only have one version of each library in the PATH. Otherwise the first version found will be used, which might not be of the correct architecture.
  5. If you don’t already have a valid JAVA_HOME environment variable pointing to the installation directory of your java, you need to create it. If you don’t have java installed on your computer, point it to <RapidMiner installation directory>/jre. Otherwise point it to the java version installed on your computer. Don’t point to the bin folder, just the install folder (e.g. C:\Program Files\Java\jre7). You have to make sure, that the java is of the same architecture as R and RapidMiner, either 32bit or 64bit.
  6. Now you can configure RapidMiner. If you click on Select JRI library file, you will be asked to enter the path to the jri library that has been installed with rJava. This is located in one of the .libpath directories noted above and more exact in<libpath directory>/rJava/jri/<architecture>. Again the architecture depends on the architecture of RapidMiner. If you want to execute 32bit RapidMiner, you must set the path to the i386 subdirectory, otherwise choose the x64 subdirectory (e.g. C:\Program Files\R\R-2.15\library\rJava\jri\x64\jri.dll or C:\Users\<USER>\Documents\R\win-library\2.15\rJava\jri\x64\jri.dll).
  7. If you have selected the file, RapidMiner will exit, since the new environment variables are still unknown and you need to restart the program manually. If you have started RapidMiner from console or another program, please restart the console or the program as well.

 

1.A ALL

If the new R Perspective has been added after restart, everything runs just fine. If not this dialog will show up again, please check if the file is in the correct directory, is accessible by RapidMiner, if the path is set to the correct R version and if all environment variables have been adapted correctly.
If you don’t manage to get it to run, please refer to our community forum. You can prevent this message from popping up every time by deactivating the R Extension in the Help / Manage Extension Menu.

 

2. Using the Console

The most obvious change in RapidMiner is the additional R perspective. It offers you a simple console to the running R instance. You can enter R code as usual and execute it by pressing enter. Arrows will give you access to the commands of your history. You can switch the console to multi-line mode using the icon in the toolbar. Then you will execute a statement or function by pressing Ctrl + Enter and cycling through history by Ctrl + Up or Ctrl + Down.

On the left a list of currently defined variables is shown. You can save and reload variables and their content to and from repository. This might be useful for storing information like performances and final results for later use. You can double click any of these results in the repository view to get a quick insight by the print() representation of the object.

The right hand side shows a plot window. To transfer the plot to RapidMiner it is needed to close the plot device. No other plot device beside JavaGD is supported. The plot can be exported to various file formats by the corresponding button on the tool bar. Zooming is supported by the mouse wheel.

The help window shows the help that is available using the usual ? command on the console. Unfortunately ?? is not supported currently.

3. Using R operators

The R Extension comes with a number of operators that use R commands for model building. You can incorporate them as other standard RapidMiner operators, saving and applying of models is also possible. The Execute Script (R) operator allows to execute various R scripts as well as consuming and delivering ExampleSets and generic R objects. Please refer to the operator documentation for more details.

4. Acknowledgements

First of all the authors of this extensions have to thank Bernd Bischl, Technical University of Dortmund, for the kindly provided advice. Without his knowledge the publication of the extension would have been delayed for months. Additionally all included operators are based on his very useful MLR package (http://mlr.r-forge.r-project.org), this has saved us a hell of work. The extension is based upon rJava, JavaGD and JRI, which are all developed and maintained by Simon Urbanek. Thanks to his work Java developers are able to access R without writing native code.

 

 

 

 

 

 

 

OLD

left for reference purpose (in case something breaks)

These sites provide more generic instructions
http://www.e-lico.eu/r-extension.html
http://www.slideshare.net/raz3366/rapid-miner-r-extension-5

This what has worked for me

Install Java

http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

Install R

http://cran.r-project.org/bin/linux/ubuntu/README

Install rJava

You can install rJava by following:

sudo apt-get install r-cran-rjava

or (not recommended):

sudo R
install.packages("rJava")

 

Set Environment Variables

Simplest approach is to add environment to the top of the your /rapidminer/scripts/RapidMinerGUI
/rapidminer/scripts/rapidminer

export JAVA_HOME=/usr/lib/jvm/java-7-oracle/
export R_HOME=/usr/lib/R/

Alternative (not recommended) is to set them as following https://help.ubuntu.com/community/EnvironmentVariables

After launching RapidMiner you may get prompted for:
/usr/lib/R/site-library/rJava/jri/libjri.so

You can also specify it in RM directly:
Tools/Preferences/R/rapidminer.r.native lib = /usr/lib/R/site-library/rJava/jri/libjri.so

Keywords:
linux ubuntu rapidminer rm r extension install instal setup set up

This is the error you may get if things are not set up properly

R_HOME is not set. Please set all required environment variables before running this program.
Unable to start R
Nov 16, 2012 7:07:59 PM com.rapidminer.tools.r.JRIRSession initializeEngine
SEVERE: Could not initialize R via JRI. Reason: Unable to initialize R
Nov 16, 2012 7:07:59 PM com.rapidminer.gui.ProcessThread run
SEVERE: Process failed: Could not initiate session with native R. Try using server. Reason: Could not initialize R via JRI. Reason: Unable to initialize R
com.rapidminer.operator.OperatorException: Could not initiate session with native R. Try using server. Reason: Could not initialize R via JRI. Reason: Unable to initialize R
at com.rapidminer.tools.r.RSessionManager.acquireSession(RSessionManager.java:239)
at com.rapidminer.tools.r.RSessionManager.acquireSession(RSessionManager.java:196)
at com.rapidminer.operator.r.GenericROperator.doWork(GenericROperator.java:105)
at com.rapidminer.operator.Operator.execute(Operator.java:834)
at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:711)
at com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:379)
at com.rapidminer.operator.Operator.execute(Operator.java:834)
at com.rapidminer.Process.run(Process.java:925)
at com.rapidminer.Process.run(Process.java:848)
at com.rapidminer.Process.run(Process.java:807)
at com.rapidminer.Process.run(Process.java:802)
at com.rapidminer.Process.run(Process.java:792)
at com.rapidminer.gui.ProcessThread.run(ProcessThread.java:63)
Caused by: org.rosuda.REngine.REngineException: Could not initialize R via JRI. Reason: Unable to initialize R
at com.rapidminer.tools.r.JRIRSession.initializeEngine(JRIRSession.java:324)
at com.rapidminer.tools.r.JRIRSession.<init>(JRIRSession.java:78)
at com.rapidminer.tools.r.RSessionManager.acquireSession(RSessionManager.java:235)
… 13 more
Caused by: org.rosuda.REngine.REngineException: Unable to initialize R
at org.rosuda.JRI.JRIEngine.<init>(JRIEngine.java:233)
at com.rapidminer.tools.r.JRIRSession.initializeEngine(JRIRSession.java:320)
… 15 more

Nov 16, 2012 7:07:59 PM com.rapidminer.gui.ProcessThread run
SEVERE: Here: Process[1] (Process)
subprocess ‘Main Process’
==> +- Generate Vector[1] (Generate Vector)
mac osx lion lepard os x

About Neil Rubens

see http://ActiveIntelligence.org

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Install R Extension for RapidMiner on Ubuntu Linux or OSX

  1. Pingback: Code Hamster » How to install R-extention in RapidMiner for Ubuntu?

Leave a Reply

Your email address will not be published. Required fields are marked *

*