Interfaces/R/Rserve/Installation

From J Wiki
< Interfaces‎ | R‎ | Rserve
Jump to navigation Jump to search
Rserve | Installation | Methods | Formats | Examples | Quirks | Extensions

1. Install R in the usual way, then install the latest binary version of Rserve as a package from CRAN from within R, i.e. load R, and enter:

install.packages("Rserve")

Information.png If you download and install the Rserve package manually, make sure that the version is 0.5 or later.

2. Start the Rserve server. You can do so in an R session with: }} 2. Start the Rserve server. You can do so in an R session with:

library(Rserve)
Rserve()

Alternatively, in a terminal/command prompt, enter:

R CMD Rserve                        (Linux)
<path>\R.exe CMD <path>\Rserve.exe  (Windows)

Information.png These commands may fail on Rserve not found or R.dll not found for Linux and Windows respectively. If so, a workaround is to copy the Rserve executable into the bin subdirectory of R, e.g. to /usr/lib/R/bin/Rserve or Program Files\R\R-X.X.X\bin\Rserve.exe

If you use the interface often, you may want to create a shortcut for starting Rserve. For Windows, an example entry for the Target of the shortcut might be:

If you use the interface often, you may want to create a shortcut for starting Rserve. For Windows, an example entry for the Target of the shortcut might be:

"C:\Program Files\R\R-X.X.X\bin\R.exe" CMD C:\Progra~1\R\R-X.X.X\library\Rserve\Rserve.exe

or in later 32-bit vs 64-bit versions of R

"C:\Program Files\R\R-X.X.X\bin\i386\R.exe" CMD C:\Progra~1\R\R-X.X.X\library\Rserve\libs\i386\Rserve.exe
"C:\Program Files\R\R-X.X.X\bin\x64\R.exe" CMD C:\Progra~1\R\R-X.X.X\library\Rserve\libs\x64\Rserve.exe

Information.png If the path to Rserve.exe includes spaces, enclosing it in double quotes will not work. A workaround is to use the short directory name as in the examples above.

3. In J, install the stats/r addon with Package Manager.

Then try:

3. In J, install the stats/r addon with Package Manager.

Then try:

   load 'stats/r/rserve'
   Rget 'rnorm(5)'
2.11491 1.4127 _0.37932 1.62199 _1.16579