R Statistics for PCM

Aus SDQ-Wiki

The following step-by-step instructions aid in enabling the link between the statistics tool R and the PCM on Windows and Mac. Please always check carefully whether the needed files are actually located at the locations mentioned below. If not, update the paths accordingly.

  • Install version 2.12.0 (Unix, Windows, Mac) of R (Note: Tested only with this version on Windows and Mac)
    • After the installation, open R and use the menu package and sub-menu install package to install the package rJava and the package plotrix. Alternatively, locate the packages in the CRAN repository, download the zip file and install manually.
      • On Windows you should start R with admin privileges, so you don't have to adjust variable paths later. You can install plotrix by using this command: install.packages("plotrix", .Library)
      • rJava can no longer be installed automatically from the repository. So it has to be downloaded from here [1] and be installed using the install packages from local zip file menu entry from the package menu.
        • If you are already using a user library, the menu will install the package into the user library by default. To install it to the global library you can use this command: install.packages('C:\\...\\rJava_0.9-3.zip', .Library, repos=NULL)
    • Set the R_HOME environment variable to the R installation directory
      • Example MacOS X: R_HOME=/Library/Frameworks/R.framework/Versions/Current/Resources/, Instructions, Datei:Environment.plist.zip
      • Example Windows: System -> Environment Variables R_HOME=C:\Programme\R\R-2.12.0
    • Put the bin directory of your R installation in your systems path environment variable.
      • On Windows
        • if the packages are installed in the R program folder (with admin rights): Put the the following additional entries to the PATH: %R_HOME%\bin\i386;%R_HOME%\library\rJava\libs\i386;%R_HOME%\library\rJava\jri\i386
          • Use the i386 folder (containing the 32-bit version) on 64-bit systems, too. The 64-bit version in the x64 folder does not work with the PCM tools (at least in our test setup with a 32-bit Eclipse).
          • Some systems, however, might require the x64 libs (experienced with a 64-bit Eclipse on a 64-bit AMD machine). Then replace the "i386" with "x64" in the path variables.
        • On Windows 7, if you have not installed the rjava package with administrators privileges, you will find the required files at <your home dir>/Documents/R/win-library/2.12/rjava/jri. So the PATH should be %R_HOME%\bin\i386;<your home dir>\Documents\R\win-library\2.12\rJava\libs\i386;<your home dir>\Documents\R\win-library\2.12\rJava\jri\i386 or similar. You also have to use this path below for the Eclipse setting.
        • You can check the validity of the entries by pasting them into the explorer address bar and hitting return.
      • On MacOS X: This step is not necessary
  • Configure your eclipse PCM installation to enable R support:
    • Insert a line into the eclipse.ini in the directory of your eclipse installation (Eclipse.app/Contents/MacOS on MacOS X) that sets the java.library.path to the directory containing the file jri.dll. This dynamic linked library is part of rJava and necessary to enable the communication between the PCM and R. Assuming the path to your R installation is C:\Programme\R\R-2.12.0 you would therefore have to enter the line -Djava.library.path=C:\Programme\R\R-2.12.0\library\rJava\jri. Please note that the line is not allowed to show quotation marks, even if there are spaces in the path to your local R installation, otherwise the connection cannot be established and an error will be shown that the library could not be found.
      • Example Windows: -Djava.library.path=C:\Programme\R\R-2.12.0\library\rJava\jri
      • Example Windows7/64Bit: -Djava.library.path=C:\Program Files\R\R-2.12.0\library\rJava\jri\x64 (notice the "x64" at the end of the path)
      • Example Windows packages installed without admin rights: -Djava.library.path=C:\Users\Anne\Documents\R\win-library\2.12\rJava\jri\x64
      • Example MacOS X (Multi-User R installation): -Djava.library.path=/Library/Frameworks/R.framework/Versions/Current/Resources/library/rJava/jri
  • Make sure the environment variables are correctly set
    • Windows: Restart your eclipse (if started from a command shell this needs to be closed and opened as well)
    • MacOS X: Logoff and login or restart your computer. The setting can be checked in Terminal with the command set.

If you use the rJava link and get an ACCESS VIOLATION you can solve the issue by removing the environment variable R_HOME.

When you run a simulation in PCM, the visualizations offered for result sensors include R visualizations.